android定位问题 GPS 基站定位 WiFi lbsgps基站定位lbswifi 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可是我们项目不允许使用第三方的定位API,您有没有好的建议呀,有好的例子没,万分感激 其实都是自己注册个locationlistener,在onLocationChanged回掉里处理这个location数据的,你可以搜索下网络定位和基站定位 楼上说的对,实现locationlistener的onLocationChanged,onProviderDisabled,onProviderEnabled,onStatusChanged接口。 但是基站定位和wifi定位(IP)还是需要第三方包依赖的啊,否则你就得自己搭建基站数据库,拿到所有基站的数据,ip也是一样,才能进行解析。 private android.location.LocationManager mLocationManager;LocationListener [] mLocationListeners = new LocationListener[] { new LocationListener(android.location.LocationManager.GPS_PROVIDER), new LocationListener(android.location.LocationManager.NETWORK_PROVIDER) };if (mLocationManager == null) { mLocationManager = (android.location.LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); } if (mLocationManager != null) { try { mLocationManager.requestLocationUpdates( android.location.LocationManager.NETWORK_PROVIDER, 1000, 0F, mLocationListeners[1]); } catch (SecurityException ex) { Log.i(TAG, "fail to request location update, ignore", ex); } catch (IllegalArgumentException ex) { Log.d(TAG, "provider does not exist " + ex.getMessage()); } try { mLocationManager.requestLocationUpdates( android.location.LocationManager.GPS_PROVIDER, 1000, 0F, mLocationListeners[0]); } catch (SecurityException ex) { Log.i(TAG, "fail to request location update, ignore", ex); } catch (IllegalArgumentException ex) { Log.d(TAG, "provider does not exist " + ex.getMessage()); } Log.d(TAG, "startReceivingLocationUpdates"); } 如此 你就注册了两个 provider , GPS_PROVIDER & NETWORK_PROVIDER。 但是还是有问题 gps 精度高 可靠, 但是稳定性差 , network方式 速度快 但是不可靠 ,因为位置取决于你使用的代理等原因。至于你的初衷“系统根据网络化境做出有效的定位方式” ,这个可以做一个互动选择让用户自行选定 如果gps获得不了位置 使用网络位置,如果两种方式都有位置信息,且误差超过一定程度 ,让用户自行决定想使用哪个。 现在Google的网络定位API根本就用不了,这个是很难实现的,而且我还想集成基站定位方式,所以说只有GPS和基站两种方式可以实现定位了 google 的地图服务用不了,就用 baidu的,高德也有借口。 android 截屏getDrawingCache()==null android游戏图片 android系统对话框修改和alterdialog修改 问大家一个模拟按键的问题 求助 android模拟器创建socket连接pc时老报错,如何解决? android 电子书阅读器,闹钟提醒 android home键唤醒原理是什么? zirco 浏览器 安卓版的 浏览isapi扩展 中文乱码 请问怎么解决 类似snapchat动态滤镜贴纸效果 Intent 跳转的问题,again Intent页面跳转语法求纠正
其实都是自己注册个locationlistener,在onLocationChanged回掉里处理这个location数据的,你可以搜索下网络定位和基站定位
LocationListener [] mLocationListeners = new LocationListener[] {
new LocationListener(android.location.LocationManager.GPS_PROVIDER),
new LocationListener(android.location.LocationManager.NETWORK_PROVIDER)
};
if (mLocationManager == null) {
mLocationManager = (android.location.LocationManager)
mContext.getSystemService(Context.LOCATION_SERVICE);
}
if (mLocationManager != null) {
try {
mLocationManager.requestLocationUpdates(
android.location.LocationManager.NETWORK_PROVIDER,
1000,
0F,
mLocationListeners[1]);
} catch (SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "provider does not exist " + ex.getMessage());
}
try {
mLocationManager.requestLocationUpdates(
android.location.LocationManager.GPS_PROVIDER,
1000,
0F,
mLocationListeners[0]);
} catch (SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "provider does not exist " + ex.getMessage());
}
Log.d(TAG, "startReceivingLocationUpdates");
}