2012-04-13 59 views

回答

1

如果你是在模拟器上测试这个,这是非常正常的行为。状态栏中的GPS图标永远不会消失。

如果您正在硬件上测试此功能,或者您多次呼叫requestLocationUpdates()(并且未删除其他更新),或者硬件上的其他功能可能使用GPS。

+0

Thx先生,我在设备上测试..但我的代码就像当计时器命中时,我要求locationManager通过locationManager.requestLocationUpdates(bestProvider,10 * 1000,1,listener)获取更新;然后在听者I HV写入公共无效onLocationChanged(地点位置){ \t \t \t \t \t \t FileUtils.save(位置,mContext); \t \t \t locationManager.removeUpdates(this); \t \t \t \t \t}所以按我的意见也没办法,我的代码请求更新了......所以,请告诉我任何代码修改我HV做.. ​​ – NullPointerException 2012-04-14 09:46:57

+0

虽然我对所有的requestLocationUpdates做removeUpdates我发起,它只发生在一些设备上,比如三星Galaxy S2。但似乎GPS闪烁的图标在几秒钟后消失(通常少于30) – Erwan 2013-05-29 07:20:01

11

如果你在你的mapView中显示你的位置和/或指南针,你必须禁用它们。如果你不这样做,GPS仍然有效。

例:

private MapView mapView; 
private MyLocationOverlay Location; 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.frame_layout); 

    mapView = (MapView) this.findViewById(R.id.mapView); 
    Location = new MyLocationOverlay(this, mapView); 
    Location.enableMyLocation(); 
    Location.enableCompass(); 
    mapView.getOverlays().add(Location); 
} 

@Override 
public void onDestroy() { 
    Location.disableMyLocation(); 
    Location.disableCompass(); 
} 
+2

这对我来说是答案。谢谢!对于更新后的Google Maps api,我做了这个:'map.setMyLocationEnabled(false);' – Robert 2015-09-15 23:22:16

3

除了上述问题的答案,在你所描述的情况,我想建议仔细检查在项目中使用第三方库,特别是一些分析库。

我有一个大伤脑筋我才意识到,GPS图标是由安装不正确(FlurryAgent.setReportLocation(true)设置和onEndSession()没有在onStop()调用)乱舞造成的。