I am getting the GPS value in background. For that Am using Service for background process. If GPS is disabled means, I used the below code.
Intent myIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
It is working when the app is running in the foreground, but it is not working in the background.
I also use the AlarmManager and a BroadcastReceiver.
Can anyone please help me?
Service won’t run for long time.You have to use AlaramManager
For Long run process.
See the below post
android: running a background task using AlarmManager