当请求内部位置更新时出现此错误service。授予位置权限,LocationManager不为空,Provider不为空。LocationManager: [LocationManager] requestLocationUpdates(), java.lang.RuntimeException at android.location.LocationManager.requestLocationUpdates(LocationManager.java:1013) at android.location.LocationManager.requestLocationUpdates(LocationManager.java:595) at com.trackinglibrary.service.DataService.createAndRequestLocationUpdates(DataService.java:759) at com.trackinglibrary.service.DataService.onStartCommand(DataService.java:252) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3694) at android.app.ActivityThread.access$1600(ActivityThread.java:202) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:107) 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)我在里面调用的位置代码 onStartCommand():@SuppressLint("MissingPermission") private void createAndRequestLocationUpdates() { try { if (!TrackThatUtils.isLocationEnabled(getApplicationContext())) { Log.e(TAG, "Location is disable."); return; } if (locationManager == null) { locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE); addProximityAlert(); } if (locationManager == null || !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { Log.e(TAG, "Location provider is disable."); return; }
2 回答
慕码人2483693
TA贡献1860条经验 获得超9个赞
添加回答
举报
0/150
提交
取消