Taras Mazepa
Taras Mazepa

Reputation: 642

Can I listen for GPS changes?

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?

Upvotes: 3

Views: 4411

Answers (2)

me.at.coding
me.at.coding

Reputation: 17604

You can monitor android system settings, see Monitor Android system settings values

Upvotes: 1

2red13
2red13

Reputation: 11217

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
}

}

Upvotes: 6

Related Questions