Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect if an app is started/resumed from 'outside' the app
    primarykey
    data
    text
    <p>I'm currently concepting a feature for an app, where I'd like a general method/approach to detect if the app itself was started or resumed from '<em>outside</em>' the app.</p> <p>'<em>Outside</em>', in this case, means:</p> <ul> <li>app was started/resumed by the launcher icon</li> <li>app was started/resumed by pressing the 'app button' from a navigation bar/key (like on a nexus 7)</li> <li>app was started/resumed from a notification</li> <li>app was started/resumed from 'somewhere else'</li> </ul> <p>The use case for this feature is the following:</p> <ul> <li>The app has a 'multi-user-ability' that allows the user(s) to create one ore more profiles for his/her data</li> <li>A single profile may be pin/password protected to 'hide' the data from other user(s) of the app, or 'hide' data from other user(s) of the device where the app is installed <ul> <li>If a profile has a password set, the app will show some kind of a lock screen to the current user when the app is started/resumed <ul> <li>If entered correctly, the app will start normally showing the data of the last select profile</li> <li>If entered incorrectly, the app will start with a 'neutral' profile or no profile at all</li> </ul></li> </ul></li> </ul> <p>I've searched the web for ideas, and found relevant posts on stackoverflow only:</p> <ul> <li><a href="https://stackoverflow.com/questions/4789300/is-there-any-way-to-distinguish-between-an-android-activity-onresume-from-the-ho">Is there any way to distinguish between an Android Activity onResume from the home screen?</a></li> <li><a href="https://stackoverflow.com/questions/5447912/android-detecting-application-launch-from-home-or-history">Android - detecting application launch from home or history</a></li> <li><a href="https://stackoverflow.com/questions/5582432/determine-if-app-was-launched-from-home-screen">Determine if app was launched from home screen?</a></li> </ul> <p>From what I've read and learned so far is, that a solution seems to be more complex than I've thought and that there's no out of the box solution for this.</p> <p>I'm currently thinking about a <em>time-flag based</em> approach to implement this feature:</p> <ul> <li>set a time flag as a member variable of an affected activity</li> <li><code>onCreate(Bundle savedInstanceState)</code> --> flag is set to 'null' before checking the savedInstanceState Budle for data <ul> <li>this detects an activity start --> if password is set --> show the lock screen </li> </ul></li> <li><code>onSaveInstanceState(Bundle)</code> --> set time flag to the 'current time'</li> <li>if <code>onCreate(Bundle savedInstanceState)</code> is resumed, savedInstanceState will contain a time flag <ul> <li>calculate a diff between the current time and the time the app was paused last</li> <li>if this diff is above a certain threshold , e.g. 30 minutes --> and if the password is set --> show the lock screen</li> </ul></li> </ul> <p>Maybe some of you have already implemented something similiar or do have some input to this matter/approach. I'd be glad to hear your ideas.</p> <p>Cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload