GPS位置变更通知

时间:2011-04-05 10:27:34

标签: android locationmanager

我可以收到有关GPS位置变化的通知吗?

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:0)

您可以使用BroadcastReceiver

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

点击此处查看示例

Detecting GPS on/off switch in Android phones