Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble Implementing custom lock screen (background activities issue)
    primarykey
    data
    text
    <p>Im building a custom home screen with a custom lockscreen.</p> <p>When the screen turn off, I launch the lock screen (activity), However, when the lock screen is killed (by "finish()"), it goes back to the last activity in my homescreen apk, and not to the real activity (apk) that was visible right before the screen went off.</p> <p>For example, if i'm in Calculator application, or in Clock applicaiton, And the lock screen turns on, When the lock screen activity is finished, It doesn't return to Calculator/Clock</p> <p>Here's where I register the lock screen (in the main launcher activity) for receiving screen on/off events:</p> <pre><code>private void doLockScreenOperations() { KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE); lock.disableKeyguard(); IntentFilter lockfiFilter = new IntentFilter(); lockfiFilter.addAction(Intent.ACTION_SCREEN_OFF); lockfiFilter.addAction(Intent.ACTION_SCREEN_ON); getApplicationContext().registerReceiver(new LockScreenReceiver(), lockfiFilter); } </code></pre> <p>Here's the receiver itself, where I launch the lock screen's activity:</p> <pre><code>public class LockScreenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(Intent.ACTION_SCREEN_OFF)) { if (LockScreenActivity.isLockScreenAlive == false) { Intent lockIntent = new Intent(context, LockScreenActivity.class); lockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(lockIntent); } } else if (action.equals(Intent.ACTION_SCREEN_ON)) { } } } </code></pre> <p>The LockScreenActivity is, at that moment, a simple activity with a button that is called finish() when the button is clicked.</p> <p>I have no idea how to fix this.</p> <p>Thanks in advance!</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.
    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