Note that there are some explanatory texts on larger screens.

plurals
  1. POFollow up on Password protect launch of android application
    text
    copied!<p>Following up on <a href="https://stackoverflow.com/a/3448189">https://stackoverflow.com/a/3448189</a>, what is the best way to actually <em>show</em> the password screen?</p> <p>My first try was starting a SubActivity with a LockActivity:</p> <pre><code>// MainActivity.java public void onResume() { super.onResume(); ApplicationState state = ((ApplicationState) getApplication()); if ((new Date().getTime() - state.mLastPause) &gt; 5000) { // Prompt for password if more than 5 seconds since last pause Intent intent = new Intent(this, LockActivity.class); startActivityForResult(intent, UNLOCKED); } } </code></pre> <p>However, this causes the MainActivity to be paused again after getting unlocked if the LockActivity is shown longer than 5 seconds.</p> <p>So, I have some things in mind:</p> <ol> <li>Use <code>Fragments</code> to show the Main screen or the Lock screen inside of MainActivity.</li> <li>Show a <code>Dialog</code> as Lock screen (not preferred).</li> <li>Using several <code>if ... else</code> branches to check whether a password has been set <strong>and</strong> the MainActivity has been paused longer than five seconds.</li> </ol> <p>To give you an example, I would like to achieve the same behavior as in the Dropbox app (using the "Passcode lock" option).</p> <p>What is the correct way to handle this?</p> <p>P.S. I'm not sure whether I should have posted this as a question to the original question, thus digging out the old thread. I felt like posting a new question is a cleaner solution.</p>
 

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