2012-02-01 15 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