On my Android phone, if I am using the Maps app to navigate, and then lock the phone with the lock button, I am able to unlock again and continue navigating without really unlocking my phone (that is, I don't need to enter my pin, but I also cannot access anything else on my phone before I unlock properly). Is it possible to achieve this behavior in my own apps, and if so, how?
To try to be more clear, this is what I'm hoping to achieve:
Is such behavior possible to implement in my app?
You can use setShowWhenLocked
in your Activity (https://developer.android.com/reference/android/app/Activity#setShowWhenLocked(boolean))
Specifies whether an Activity should be shown on top of the lock screen whenever the lockscreen is up and the activity is resumed. Normally an activity will be transitioned to the stopped state if it is started while the lockscreen is up, but with this flag set the activity will remain in the resumed state visible on-top of the lock screen. This value can be set as a manifest attribute using R.attr.showWhenLocked.
Edit: If you also need to support older APIs (taken from here: https://stackoverflow.com/a/50644346/1386873)
if (Build.VERSION.SDK_INT >= 27) {
setShowWhenLocked(true)
setTurnScreenOn(true)
} else {
this.window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
}