我可以知道什么时候/如果用户在 API 级别 26(Oreo) 中禁用了 "background activity" 吗?

Can I know when / if user disabled "background activity" in API level 26(Oreo)?

我的目标不是 26,但我想知道用户何时禁用 'background activity',如 documentation 中所述(在发生时显示通知)。

有什么我可以听的意图吗?或者以其他方式以编程方式知道它当前是否被禁用?

我设法找到了一种方法来了解用户是否禁用了 'background activity'。 不确定它是否是最佳解决方案,但看起来它正在运行:

在 onDestroy 我的粘性服务时,我安排了一个有时间限制的工作(使用 JobScheduler)。

当作业运行时,我检查我的粘性服务是否仍在被销毁,并且没有再次启动。 如果是这种情况,我尝试从作业中启动服务,并检查是否成功:

ComponentName componentName = startService(serviceIntent);
if(componentName == null){
    // we could not start the service, so user probably disabled the background activity
}