2011-11-07 18 views
0

如何配置清單以聊天新的位置座標? 我可以使用BroardcastReceiver獲取新座標嗎?配置清單以捕獲可用的新位置

+0

對不起,但是當GPS信號不可用時,另一個應用程序如何獲得GPS信號呢? – m0skit0

+0

是的,你是對的,但我想像一個模擬的位置服務。這樣有可能嗎? – adev

回答

1

如果您的清單中的應用元素每當獲得新的GPS座標,它會調用的onReceive在LocationChangedReceiver類中添加此:

<receiver android:name=".location.LocationChangedReceiver" /> 

LocationChangedReceiver可能是這樣的:

public class LocationChangedReceiver extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     String locationKey = LocationManager.KEY_LOCATION_CHANGED; 

     if (intent.hasExtra(locationKey)) { 
      Location location = (Location) intent.getExtras().get(locationKey); 
      Log.d(TAG, "Got Location! Lat:" + location.getLatitude() + ", Lon:" + location.getLongitude() + ", Alt:" + location.getAltitude() + ", Acc:" + location.getAccuracy()); 

      return; 
     } 

    } 
} 
0

如果我理解正確的問題,您可能會發現passive provider有幫助。

有幫助

+0

看起來很有幫助。現在我來看看它是否正是我所需要的。 – adev