Android — What happens when device is unlocked?

2019-01-22 07:33发布

I am trying to understand the intents that get launched when the device is unlocked.

For eg: Say my activity is running, and I press the power button (screen off, to lock the phone). INTENT.ACTION_SCREEN_OFF is launched. The activity is paused and the screen goes blank.

Now, when I press the power button again (INTENT.SCREEN_ON gets launched), the activity's onResume method is called. But the device is not yet unlocked.

What happens when the device is unlocked? To put it simply, what is the intent's action and category?

2条回答
一纸荒年 Trace。
2楼-- · 2019-01-22 07:52

Additionally to

ACTION_USER_PRESENT

Broadcast Action: Sent when the user is present after device wakes up (e.g when the keyguard is gone). (API Lvl 3)

Android SDK 24 added

ACTION_USER_UNLOCKED

Broadcast Action: Sent when the credential-encrypted private storage has become unlocked for the target user. This is only sent to registered receivers, not manifest receivers.

查看更多
3楼-- · 2019-01-22 07:54
登录 后发表回答