Joe*_*eyG 24 android android-service
在以前的Android版本中,我使用此方法查找来自其他应用程序的服务是否已启动并正在运行.它对我来说可靠:
ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
Run Code Online (Sandbox Code Playgroud)
但是,对于Android O,现在不推荐使用此功能,只会返回有关调用应用服务的信息.我已经研究过其他解决方案,但我不想要求用户提供更多权限(UsageStatsManager,NotificationManager等).
是否有另一种解决方案可以获取Android O中是否有来自其他应用的服务正在运行?
根据文档:
As of O, this method is no longer available to third party applications.
For backwards compatibility, it will still return the caller's own services.
Run Code Online (Sandbox Code Playgroud)
但这个解决方案可能会有帮助:How to check if a service is running on Android?
| 归档时间: |
|
| 查看次数: |
2755 次 |
| 最近记录: |