android-地理编码器是否可以在模拟器上工作

android-地理编码器是否可以在模拟器上工作,第1张

概述我正在使用地理编码器,但它在我的设备上工作正常,但在模拟器上却无法工作,但在2.2和4.2.2上尝试了一下却无法正常工作;这是我的代码:GeocodermyLocation=newGeocoder(AzanTime.this,Locale.getDefault());List<Address>myList=null;try{myList=myLocation.getFrom

我正在使用地理编码器,但它在我的设备上工作正常,但在模拟器上却无法工作,但在2.2和4.2.2上尝试了一下却无法正常工作;

这是我的代码:

Geocoder myLocation = new Geocoder(AzanTime.this, Locale.getDefault());List<Address> myList=null;try {    myList = myLocation.getFromLocation(latitude,longitude, 1);} catch (IOException e) {    // Todo auto-generated catch block    e.printstacktrace();}Address address = (Address) myList.get(0);String addressstr = "";if(address.getAddressline(0)!=null){    addressstr += address.getAddressline(0);}

和logcat:

01-11 09:31:07.573: E/AndroIDRuntime(788): FATAL EXCEPTION: main01-11 09:31:07.573: E/AndroIDRuntime(788): java.lang.RuntimeException: Unable to start activity ComponentInfo{amina.myhomebusiness.IslamicApps.FortressOfTheMuslimExplanation/amina.myhomebusiness.IslamicApps.FortressOfTheMuslimExplanation.AzanTime}: java.lang.IllegalArgumentException: provIDer doesn't exisit: null01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2180)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread.access0(ActivityThread.java:141)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.os.Handler.dispatchMessage(Handler.java:99)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.os.Looper.loop(Looper.java:137)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread.main(ActivityThread.java:5041)01-11 09:31:07.573: E/AndroIDRuntime(788):  at java.lang.reflect.Method.invokeNative(Native Method)01-11 09:31:07.573: E/AndroIDRuntime(788):  at java.lang.reflect.Method.invoke(Method.java:511)01-11 09:31:07.573: E/AndroIDRuntime(788):  at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)01-11 09:31:07.573: E/AndroIDRuntime(788):  at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:560)01-11 09:31:07.573: E/AndroIDRuntime(788):  at dalvik.system.NativeStart.main(Native Method)01-11 09:31:07.573: E/AndroIDRuntime(788): Caused by: java.lang.IllegalArgumentException: provIDer doesn't exisit: null01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.os.Parcel.readException(Parcel.java:1429)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.os.Parcel.readException(Parcel.java:1379)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:538)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.location.LocationManager.requestLocationUpdates(LocationManager.java:836)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.location.LocationManager.requestLocationUpdates(LocationManager.java:430)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.Activity.performCreate(Activity.java:5104)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)01-11 09:31:07.573: E/AndroIDRuntime(788):  at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2144)01-11 09:31:07.573: E/AndroIDRuntime(788):  ... 11 more

解决方法:

模拟器上未安装Geocoder.
累积至Geocoder参考

The Geocoder class requires a backend service that is not included in the core androID framework. The Geocoder query methods will return an empty List if there no backend service in the platform. Use the isPresent() method to determine whether a Geocoder implementation exists.

你应该检查一下

Geocoder.isPresent()

在访问API之前.
使用自己的实现更可靠.
检查此答案以了解我的实现.
problems with android.location.geocoder

总结

以上是内存溢出为你收集整理的android-地理编码器是否可以在模拟器上工作全部内容,希望文章能够帮你解决android-地理编码器是否可以在模拟器上工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1088090.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存