开发者

GPS location change notification

开发者 https://www.devze.com 2023-02-22 07:31 出处:网络
Can I receive a notification on the GPS\'s locatio开发者_如何转开发n change?public class MyLocationListener implements LocationListener

Can I receive a notification on the GPS's locatio开发者_如何转开发n change?


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
}
}


You can use a BroadcastReceiver with

<action android:name="android.location.PROVIDERS_CHANGED" />

check here for an example

Detecting GPS on/off switch in Android phones

0

精彩评论

暂无评论...
验证码 换一张
取 消