大佬教程收集整理的这篇文章主要介绍了android – 在地图中显示当前位置时获取纬度和经度0.0,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
LOCATIOnManager = (LOCATIOnManager)getSystemservice(Context.LOCATION_serviCE); customLOCATIOnListener = new CustomLOCATIOnListener(); LOCATIOnManager.requestLOCATIOnupdates( LOCATIOnManager.GPS_PROVIDER,customLOCATIOnListener); class CustomLOCATIOnListener implements LOCATIOnListener{ ............ public void onLOCATIOnChanged(LOCATIOn argLOCATIOn) { if(LOCATIOn != null) { int latitude=(int)(argLOCATIOn.getLatitude()*1E6); int longitude=(int)(argLOCATIOn.getLongitude()*1E6); } } ........ }
你们中的任何人都知道为什么吗?
注意:我的活动扩展了MapActivity而不是LOCATIOn Listener
LOCATIOnManager = (LOCATIOnManager) context .getSystemservice(Context.LOCATION_serviCE); Criteria LOCATIOnCritera = new Criteria(); String providerName = LOCATIOnManager.getBestProvider(LOCATIOnCritera,truE); if(providerName!=null) LOCATIOn = LOCATIOnManager.getLastKNownLOCATIOn(providerName); LOCATIOnListener = new MyLOCATIOnListener(); LOCATIOnManager.requestLOCATIOnupdates(LOCATIOnManager.GPS_PROVIDER,LOCATIOnListener);
在myLOCATIOnlistener中设置您的位置对象
private class MyLOCATIOnListener implements LOCATIOnListener { public void onLOCATIOnChanged(LOCATIOn loC) { if (loc != null) { LOCATIOn = loc; } } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider,int status,Bundle extras) { } }
以上是大佬教程为你收集整理的android – 在地图中显示当前位置时获取纬度和经度0.0全部内容,希望文章能够帮你解决android – 在地图中显示当前位置时获取纬度和经度0.0所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。