如何解决LocationManagerService:在Android 9中为isAcquireLocationExemptLocked

时间:2019-04-26 01:58:10

标签: android locationmanager

这是我的代码:

我的应用程序通过位置管理器使用位置服务,Android 6〜8可以运行,但是android 9无法正常工作。

if ( ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) 
    != PackageManager.PERMISSION_GRANTED 
    && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
    {
        return;
    }

    LocationManager location_manager = (LocationManager)getSystemService( LOCATION_SERVICE );

    _google_gps_location_listener = new MyLocationListener();

    location_manager.requestLocationUpdates( LocationManager.GPS_PROVIDER , 1500 , 5 , _google_gps_location_listener, Looper.getMainLooper());

然后发生RuntimeException,我不知道要解决这个问题

我该如何解决?

D/LocationManagerService: isAcquireLocationExemptLocked --- mBackgroundAcquireLocationPackageWhitelist = {}, packageName = com.mypackage.myproject

[LocationManager] requestLocationUpdates(), 
java.lang.RuntimeException
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:1013)
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:562)
    at com.streams.taxi.driver.service.TaxiDriverLocationService.switchProvider(TaxiDriverLocationService.java:790)
    at com.streams.taxi.driver.service.TaxiDriverLocationService$1.run(TaxiDriverLocationService.java:1141)
    at android.os.Handler.handleCallback(Handler.java:874)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:198)
    at android.app.ActivityThread.main(ActivityThread.java:6729)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

0 个答案:

没有答案