How to list all services in an android device

后端 未结 2 1124
青春惊慌失措
青春惊慌失措 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 05:00

    You can enumerate all packages and retrieve their services:

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

    Compatible to API 1.

提交回复
热议问题