How to list all services in an android device

后端 未结 2 1125
青春惊慌失措
青春惊慌失措 2021-01-23 04:19

I am looking for a reliable way to programmatically find and list all available services in an Android device (both running and not running).

相关标签:
2条回答
  • 2021-01-23 04:44

    In the past I have used the following:

    List list = activityManager.getRunningServices(maxNum);

    I have created an example here

    0 讨论(0)
  • 2021-01-23 05:00

    You can enumerate all packages and retrieve their services:

    List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(PackageManager.GET_SERVICES);
    for(PackageInfo pkg : pkgs) {
      // You can now use pkg.services
    }
    

    Compatible to API 1.

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