将我的 Pixel XL 升级到 Android 10.0 版后,蓝牙低功耗 (BLE) 扫描仅在我打开位置功能时才有效。
直到现在这还不是问题,它可以在运行 Android 9.0、8.0 和 6.0.1 的多个设备上运行。
我的应用程序仅在前台使用 BluetoothLeScanner startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
我的应用程序具有 FINE_LOCATION、COARSE_LOCATION 和 BLUETOOTH 权限,我尝试添加 ACCESS_BACKGROUND_LOCATION 权限但没有运气。
Android 10.0 中是否有更严格的应用程序扫描蓝牙设备的要求,我找不到任何关于此的信息,我希望我不必要求用户打开位置以便我的应用程序工作。
我正在尝试启动一个IntentService来注册Android O上的firebase云消息.
在Android O上,不允许"在不允许的情况下"启动Intent Service,并且每个人都告诉我使用JobService而不是如何使用它.
JobInfo.Builder应该有什么限制才能有"允许它的情况",我一直得到相同的IllegalStateException
这是我的JobService
@Override
public boolean onStartJob(JobParameters params) {
Intent intent = new Intent(this, RegistrationIntentService.class);
getApplicationContext().startService(intent);
return false;
}
@Override
public boolean onStopJob(JobParameters params) {
return false;
}
public static void scheduleJob(Context context) {
ComponentName serviceComponent = new ComponentName(context, MyJobService.class);
JobInfo.Builder builder = new JobInfo.Builder(MyJobService.JOB_ID, serviceComponent);
builder.setMinimumLatency(1 * 1000); // wait at least
JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
if(jobScheduler != null) jobScheduler.schedule(builder.build());
}
Run Code Online (Sandbox Code Playgroud)