1

I'm trying to detect the unlock of the phone with the app in background.

I'm registering a receiver with registerReceiver method to detect the unlock of the phone, and apparently it only works as long as the context used is alive so I used the application context :

getApplicationContext().registerReceiver(receiver, filter);

I want to know how long I can expect this receiver to work when the user leave my application and does not use it (so when is the application context killed).

I firstly wanted to use the ACTION_USER_PRESENT in the manifest but this need for read_phone_state permission (and it would be difficult to explain to the user why the app need to make calls...).

Kusan
  • 260
  • 1
  • 11
  • Try from this .... https://stackoverflow.com/questions/20224637/a-way-to-get-unlock-event-in-android OR https://stackoverflow.com/questions/3446202/android-detect-phone-unlock-event-not-screen-on – Mohd Saquib Aug 02 '17 at 10:16
  • these are for when the app is in foreground, I have edited my title – Kusan Aug 02 '17 at 10:20
  • Ok then go through this link ... https://stackoverflow.com/questions/35139125/is-there-a-way-for-an-android-service-to-detect-when-the-device-is-locked – Mohd Saquib Aug 02 '17 at 10:22

0 Answers0