Reputation: 21
I can't receive the ACTION_USER_PRESENT Intent on Android Versions above 11. I can however receive the ACTION_SCREEN_OFF Intent Action but not the one stated above as soon as I go above Android 11.
val intentFilter = IntentFilter(ACTION_SCREEN_OFF)
intentFilter.addAction(ACTION_USER_PRESENT)
applicationContext.registerReceiver(eventReceiver, intentFilter, Manifest.permission.READ_PHONE_STATE, null, RECEIVER_NOT_EXPORTED)
I tried to look for changes to the event or its behaviour but I couldn't find anything on the web.
Upvotes: 1
Views: 376
Reputation: 497
I had the same problem. I could not receive the ACTION_USER_PRESENT
broadcast from within a BroadcastReceiver
inside a Service
although it was registered in the IntentFilter
. At the same time I could receive ACTION_SCREEN_OFF
.
The problem was that my receiver was not exported (it had the RECEIVER_NOT_EXPORTED
flag and after I modified it like so registerReceiver(serviceReceiver, serviceReceiver.getIntentFilter(), RECEIVER_EXPORTED)
I started receivieng the ACTION_USER_PRESENT
broadcast correctly.
Upvotes: 0
Reputation: 21
Seems like the app that sends the intent is missing the permission set at the "broadcastPermissions" parameter, if set null and the receiver is set to exported I can receive the intent action again. Appears to be more like a bug on googles side than a undocumented change.
Upvotes: 1