I want to listen a GPS state changes in my app, is there in android any intent-action which I can use in a broadCast receiver like an android.net.conn.CONNECTIVITY_CHANGE<
You can register a BroadcastReceiver for listening to Intent Action PROVIDERS_CHANGED_ACTION
.
or you can try this snippet
GpsStatus.Listener gpsListener = new GpsStatus.Listener() {
public void onGpsStatusChanged(int event) {
if( event == GpsStatus.GPS_EVENT_FIRST_FIX){
showMessageDialog("GPS fixed");
}
}
};
OR
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.addGpsStatusListener(new android.location.GpsStatus.Listener()
{
public void onGpsStatusChanged(int event)
{
switch(event)
{
case GPS_EVENT_STARTED:
// do your tasks
break;
case GPS_EVENT_STOPPED:
// do your tasks
break;
}
}
});