在之前的Android版本中,我使用这种方法来查找另一个应用程序中的服务是否正在运行。对我来说,它工作得可靠:
ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
然而,在Android O中,此功能已被弃用,仅会返回有关调用应用程序服务的信息。我已经研究了其他解决方案,但我不想要求用户获得更多权限(例如UsageStatsManager、NotificationManager等)。
在Android O中,是否有获取不同应用程序的服务是否正在运行的替代解决方案?