相关疑难解决方法(0)

运行时错误 - java.lang.IllegalArgumentException:provider = gps

我从我创建的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)
Run Code Online (Sandbox Code Playgroud)

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

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

    };
Run Code Online (Sandbox Code Playgroud)

gps android illegalargumentexception locationmanager

7
推荐指数
1
解决办法
7959
查看次数

引起:java.lang.IllegalArgumentException:provider = network

试图找到我的device.code的当前位置在这里.

package com.example.location;

import android.app.Activity;    
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;


public class LocationActivity extends Activity
{

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  /* Use the LocationManager class to obtain GPS locations */
  LocationManager mlocManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);

  LocationListener mlocListener = new MyLocationListener();
  mlocManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, mlocListener);
}

/* Class My Location Listener */
public class MyLocationListener implements LocationListener
{

  @Override
  public void …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
8778
查看次数