I am writing app, that collects location data, based on GPS. And i have next problem: when i try to get GPS data and GPS is turned off, i show notification that ask for turning on GPS, and it starts(on click of course) intent with "ACTION_LOCATION_SOURCE_SETTINGS". Question: how can i know that user turned it on? is there some broadcasted actions, or i can set some listener, or something else?
Asked
Active
Viewed 4,393 times
3
-
i need get it as fast as it possible. and yes i know i can start some service that can check this, but it can take a long time while user change settings, and it will cost a lot of battery and system resources. or not? – Taras Mazepa Apr 04 '11 at 09:01
-
Hey i have not worked yet with GPS applications. But this was i able to find something for you : http://android.stackexchange.com/questions/186/make-certain-apps-turn-on-gps-automatically – Kartik Domadiya Apr 04 '11 at 09:10
-
@Kartik it possibly uses in application turn on GPS through reflection i guess. that not solution for me( – Taras Mazepa Apr 04 '11 at 09:20
-
Try this one [Broadcast Receiver](http://stackoverflow.com/questions/4805269/programmatically-register-a-broadcast-receiver): i think it will help you – Kartik Domadiya Apr 04 '11 at 09:33
-
@Kartik yes but what action i should listen? – Taras Mazepa Apr 04 '11 at 12:38
2 Answers
6
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc) {
GlobalHelper.handler.post(GlobalHelper.update_location);
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
GlobalHelper.system_message(provider + " Ausgeschaltet", 0,false);
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
GlobalHelper.system_message(provider + " Eingeschaltet",0,false);
}
@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
}

2red13
- 11,197
- 8
- 40
- 52
-
OMG i forgot that in LocationListener there is such method to fire GPS state, my mistake. thank you! – Taras Mazepa Apr 04 '11 at 12:40
1
You can monitor android system settings, see Monitor Android system settings values

Community
- 1
- 1

stefan.at.kotlin
- 15,347
- 38
- 147
- 270