2012-02-01 111 views
7

我从创建的Android应用程序的用户日志中得到了此错误。到目前为止,我一直无法复制这个错误。任何帮助将不胜感激。运行时错误 - java.lang.IllegalArgumentException:provider = gps

的错误是:

java.lang.IllegalArgumentException: provider=gps 
at android.os.Parcel.readException(Parcel.java:1326) 
at android.os.Parcel.readException(Parcel.java:1276) 
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646) 
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582) 
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446) 
at com.myApp.service.DeviceManager$7.handleMessage(DeviceManager.java:470) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:130) 
at android.app.ActivityThread.main(ActivityThread.java:3835) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641) 
at dalvik.system.NativeStart.main(Native Method) 

的devicemanager位置时,它指的是:

private final Handler uihandler = new Handler() { 

@Override 
     public void handleMessage(Message msg) { 
      switch (msg.what) { 
       case MSG_TOAST: 
        Toast.makeText(DeviceManager.this, msg.arg1, Toast.LENGTH_SHORT).show(); 
        break; 

       case MSG_ENABLE_LOCATION: 
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 1,DeviceManager.this); 
        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 
          60000, 1, DeviceManager.this); 
        break; 

       case MSG_DISABLE_LOCATION: 
        mLocationManager.removeUpdates(DeviceManager.this); 
        break; 

       case MSG_STOP_SELF: 
        break; 
      } 
     } 

    }; 

回答

7

很抱歉忘记发布解决方案。问题最终是由于用户在部署位置更新中关闭了应用程序。我们无能为力!

+0

onPause中的mLocationManager.removeUpdates无效?关闭应用程序时,事物永远不会崩溃 – 2014-08-12 22:50:22

1

IllegalArgumentException如果提供者为null或不存在。确保启用了GPS提供程序。

您是否检查了这个tutorial?您是否添加了以下条目清单文件?

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
+1

是的,谢谢你我已经把它列入清单。我将ACCESS_FINE_LOCATION放入其中,因为它涵盖了网络和GPS权限。 “确保GPS提供商已启用”是什么意思?谢谢! – 2012-02-01 00:59:24

+0

如果未启用手机,请在手机上启用GPS。 – kosa 2012-02-01 01:00:09

+0

我很确定它可以在没有启用GPS的情况下运行,因为我们也启用了LocationManager.NETWORK_PROVIDER。感谢您的回应。你有什么其他想法可能导致它吗?我从我们的一个用户那里得到了这个错误,所以我只是想弄清楚是什么导致了这个错误。 – 2012-02-01 01:08:52