2012-11-26 45 views
0

使用MyLocationOverlay獲取我的位置。但是我想停止GPS onPause並重新開始onResume。我怎樣才能做到這一點 ?android MyLocationOverlay停止GPS onPause

我知道的LocationManager是方法removeUpdates ...

final MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView); 
myLocationOverlay.enableMyLocation(); 
mapView.getOverlays().add(myLocationOverlay); 

locButton.setOnClickListener(new View.OnClickListener() { 

    public void onClick(View v) { 
     // TODO Auto-generated method stub 
     myLocationOverlay.runOnFirstFix(new Runnable() { 

      public void run() { 
       // TODO Auto-generated method stub 
       mapView.getController().animateTo(myLocationOverlay.getMyLocation()); 
      } 
     });{ 

     } 
    } 
}); 

回答

0

保持到MyLocationOverlay對象的引用,當你創建它,並簡單地使用enableMyLocation()和​​3210方法分別onResume()onPause()。根據您設置代碼的方式,您可能需要在調用覆蓋層上的任何內容之前執行null檢查。