如果 GPS_PROVIDER 的状态发生变化,我会尝试获取通知。我在这里找到了以下代码(http://hejp.co.uk/android/android-gps-example/),但我没有收到通知。
- 现在我在建筑物中,无法接收 GPS 信号,所以我不会收到“状态已更改:停止服务”的通知吗?
- 何时调用 onStatusChanged?
- 我究竟做错了什么?
谢谢,
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
/* This is called when the GPS status alters */
switch (status) {
case LocationProvider.OUT_OF_SERVICE:
Log.v(tag, "Status Changed: Out of Service");
Toast.makeText(this, "Status Changed: Out of Service",
Toast.LENGTH_SHORT).show();
break;
case LocationProvider.TEMPORARILY_UNAVAILABLE:
Log.v(tag, "Status Changed: Temporarily Unavailable");
Toast.makeText(this, "Status Changed: Temporarily Unavailable",
Toast.LENGTH_SHORT).show();
break;
case LocationProvider.AVAILABLE:
Log.v(tag, "Status Changed: Available");
Toast.makeText(this, "Status Changed: Available",
Toast.LENGTH_SHORT).show();
break;
}