Android O Replacement for getRunningServices

后端 未结 2 511
盖世英雄少女心
盖世英雄少女心 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.

提交回复
热议问题