I have service for location update and detect GPS ON/OFF state by BroadcastReceiver (for example here is code https://stackoverflow.com/a/20673766/9177782). It works fine for API25 and less. But what I should use for API26+ ? This BroadcastReceiver doesn't work for API26+ because of restriction of Oreo. I need to detect GPS OFF state by my foreground location service
Asked
Active
Viewed 668 times
6
-
Did you got your answer? I'm looking for same answer – moDev Apr 08 '18 at 10:34
-
https://developer.android.com/guide/components/broadcast-exceptions.html Following implicit broadcast receiver is supported – Rahul Apr 11 '18 at 11:24
-
@Rahul Thanks mate! I will try it. This brodcast should be working: ACTION_LOCALE_CHANGED Only sent when the locale changes, which is not often. Apps might need to update their data when the locale changes. – A.M. Apr 12 '18 at 07:46
-
Are you looking for broadcast after app is closed? – moDev Apr 12 '18 at 13:03
-
@moDev Yes, I am looking for broadcast after app is closed. – A.M. Apr 12 '18 at 13:43
-
1@A.M. Did you get an answer? I'm also looking for the same – Mehta Sep 26 '18 at 06:34
-
I have the same problem. Looks like we're gonna have to use context registered receivers : https://developer.android.com/guide/components/broadcasts#context-registered-receivers – Sebek Feb 08 '19 at 13:38