【问题标题】:Runtime Error--java.lang.IllegalArgumentException: provider=gps运行时错误--java.lang.IllegalArgumentException: provider=gps
【发布时间】:2012-02-01 00:07:46
【问题描述】:

我从用户登录我创建的 Android 应用程序时收到此错误。到目前为止,我一直无法复制该错误。任何帮助将不胜感激。

错误是:

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)

它所指的设备管理器位置是:

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;
            }
        }

    };

【问题讨论】:

    标签: android gps locationmanager illegalargumentexception


    【解决方案1】:

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

    【讨论】:

    • mLocationManager.removeUpdates onPause 不起作用?关闭应用程序时,事情永远不会崩溃......
    【解决方案2】:

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

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

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

    【讨论】:

    • 是的,谢谢,我已经将它包含在清单中。我把 ACCESS_FINE_LOCATION 因为它涵盖了网络和 GPS 权限在一个。 “确保启用 GPS 提供商”是什么意思?谢谢!
    • 如果未启用,请在手机上启用 GPS。
    • 我很确定它可以在没有启用 GPS 的情况下运行,因为我们也启用了 LocationManager.NETWORK_PROVIDER。感谢您的回复。您还有其他想法可能导致它吗?我从我们的一位用户那里得到了错误,所以我只是想弄清楚是什么原因造成的。
    • 我同意 NETWORK_PROVIDER 有效。看看这个链接能不能帮到你stackoverflow.com/questions/8871825/…
    • 是的,我在发布问题之前研究了一段时间。您认为此错误可能是特定类型的手机/Android 操作系统所特有的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 2019-01-28
    相关资源
    最近更新 更多