Android O Replacement for getRunningServices

后端 未结 2 494
盖世英雄少女心
盖世英雄少女心 2020-12-29 02:23

In previous versions of Android, I used this method to find if a service from another app was up and running. It worked reliably for me:

ActivityManager mana         


        
相关标签:
2条回答
  • 2020-12-29 02:53

    It is intentional that there is no replacement for this function. It is not too clear from the documentation, but from the docs:

    Note: this method is only intended for debugging or implementing service management type user interfaces.

    Basically, using the method to check other apps services was an unintended side-effect, so Google decided to remove it. Likely for privacy/security purposes to avoid apps "sniffing" other apps/services on the user's device.

    You didn't mention your use-case, but you want to avoid asking users for permissions. However, Google is intentionally forcing developers to explicitly request permissions they need, a philosophy which you can find explained here.

    0 讨论(0)
  • 2020-12-29 03:01

    As per documentation:

    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.
    

    But may be this solution will help: How to check if a service is running on Android?

    0 讨论(0)
提交回复
热议问题