I know that there is a system broadcast called android.intent.action.SCREEN_OFF
, but I want to receive broadcast when user lock his phone not screen off.
I am developing an application that can tell user how long his phones is locked.
I know that there is a system broadcast called android.intent.action.SCREEN_OFF
, but I want to receive broadcast when user lock his phone not screen off.
I am developing an application that can tell user how long his phones is locked.
I don't see the broadcast you're asking for in the list of available broadcasts listed here https://developer.android.com/about/versions/11/reference/broadcast-intents-30). However, you could use the ACTION_SCREEN_OFF broadcast, and in its onReceive(), use one of the KeyguardManager class's methods to check if the device is locked. The method used would depend on your API version. For example, isKeyguardSecure() supports API 16 and above.