不是在模拟器运行的,是在真机器上,gps开始搜索信号,直到可以在onLocationChanged中得到经纬度信息,然后把机器拿到房间里,gps信号中断,整个过程写在onStatusChanged里的事件一次也不触发
解决方案 »
- android瀑布流图片无限多,内存溢出
- 求助蓝牙单双声道耳机与开发板蓝牙设备配对时自动断开问题
- Android牟利之道(一)--界面嵌入有米广告
- Android来电界面的滑动按钮如何实现啊?有无源代码
- (有难度)webview设置setWebChromeClient后,导致无法复制文本(100分)
- 关于Android程序更新代码
- 公开了I9088的ROM修改过程,同样适用于I9000哦,有兴趣的朋友看看,,
- webview 怎么实现window.open 创建新窗口的
- 请问,Android如何实现左滑返回啊
- 怎么在XlistView每个Item中间在加别的内容 里面有效果图,求大神解答!在弄不出要被炒了!
- 请教:如何区别点击事件和滑屏事件,不要通过判断滑动距离的那种判断方式
- 如何通过其他控件去触发listview的itemonclick事件呢?
这个跟有经纬度有关系吗,不是onlocationchange啊是onStatusChanged
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("test", "Status changed to " + status);
} public void onLocationChanged(Location location) {
// do some things
}
}What happend ON REAL DEVICE:
- Nothing. onStatusChanged is never called. Not when GPS gets fixed, not when GPS lost fix... just never. Other methods (eg. onLocationChanged) of used LocationListener are working properly.What happend ON EMULATOR:
- onStatusChanged is called when I manually set location using ddms.Expecting behavior ON REAL DEVICE:
- onStatusChanged should be called everytime the provider changed status between available or unavailable (temporarily or permanently). For example when GPS gets or lost fix.Operating system ON REAL DEVICE:
- Android 2.2, FRF85B, Google Nexus One
Comment 1 by [email protected], Aug 12, 2010 I'm also experiencing this issue, on a HTC Desire, Android 2.2
Comment 2 by [email protected], Sep 20, 2010 I am also facing the same issue on my Nexus one, Android 2.2
Comment 3 by [email protected], Oct 9, 2010 This issue is also present on Android 2.2.1, build FRG83 on a Nexus One.
Comment 4 by [email protected], Feb 10, 2011 Same behavior on Nexus S. LocationListener is registered but onStatusChanged is never called.
Nexus S Android 2.3.1
Kernel Version 2.6.35.7-g7f1638a
Build Number GRH78OnStatusChanged DOES get called on the Samsung Galaxy S running 2.1
Comment 5 by [email protected], Feb 20, 2011 Same issue on SH-03C, Android 2.1-update1.
OnStatusChanged does NOT get called.
Comment 6 by [email protected], May 19, 2011 Exactly the same issue on HTC Desire Android 2.2
onStatusChanged is not called.
Comment 8 by [email protected], Jul 28, 2011 Same issue on Samsung Galaxy S running 2.2
Comment 10 by [email protected], Aug 3, 2011 Updated to 2.3.3, still the same
Also tested on Galaxy S 2 with 2.3.3, no luck.
Also tested on old G1 HTC 1.6, it works on that device. Strange..
Comment 11 by [email protected], Aug 6, 2011 On Nexus One 2.3.4 onStatusChanged is not called too - what is more interesting it did work on Android 1.6other finding:
after acquiring GpsSatellite objects from GpsStatus none of them have isUsedInFix set to false
①先要获取一个管理器:
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
②再定义一个监听:
LocationListener locationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
switch (status) {
// GPS状态为可见时
case LocationProvider.AVAILABLE:
Log.e("TAG", "当前GPS状态为可见状态");
et01.setText("LocationProvider.AVAILABLE");
break;
// GPS状态为服务区外时
case LocationProvider.OUT_OF_SERVICE:
Log.e("TAG", "当前GPS状态为服务区外状态");
et01.setText("LocationProvider.OUT_OF_SERVICE");
break;
// GPS状态为暂停服务时
case LocationProvider.TEMPORARILY_UNAVAILABLE:
Log.e("TAG", "当前GPS状态为暂停服务状态");
et01.setText("LocationProvider.TEMPORARILY_UNAVAILABLE");
break;
}
} @Override
public void onProviderEnabled(String provider) {
Log.e("TAG", "onProviderEnabled");
et01.setText("onProviderEnabled");
} @Override
public void onProviderDisabled(String provider) {
Log.e("TAG", "onProviderDisabled");
et01.setText("onProviderDisabled");
} @Override
public void onLocationChanged(Location location) {
// updateView(location);
Log.e("TAG", "时间:" + location.getTime());
Log.e("TAG", "经度:" + location.getLongitude());
Log.e("TAG", "纬度:" + location.getLatitude());
Log.e("TAG", "海拔:" + location.getAltitude());
et01.setText("时间:" + location.getTime() + "经度:" + location.getLongitude() + "纬度:"
+ location.getLatitude() + "海拔:" + location.getAltitude());
}
};
③邦定监听到管理器上(provider直接使用GPS_PROVIDER,不考虑NETWORK_PROVIDER):
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);问题是,测试时(真实设备非虚拟设备),似乎永远无法触发locationListener的onStatusChanged方法,请教高手,何时能触发这个方法,再就解释一下方法中的各个状态,多谢!!!