Until now, you could easily get the installed application information in the terminal by using getPackageManager () # getInstalledPackages (). However, from Android 11 (API level 30), only system application information can be obtained by simply writing the following code.
** Example) Log output of the installed application in the device **
MainActivity.java
PackageManager pm = getApplicationContext().getPackageManager();
List<PackageInfo> appInfoList = pm.getInstalledPackages(0);
for(int i =0;i<appInfoList.size();i++){
Log.d("MainActivity",appInfoList.get(i).applicationInfo.loadLabel(pm).toString());
}
Since Android 11 (API level 30), security has become stricter, and access to external packages must be specified in Manifest.
I write the permission description in AndroidManifest.xml.
AndroidManifest.xml
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
… It seems to be a deprecated method because it allows everything.
Originally, it may be the correct way to enclose it in <queries>
and specify it individually.
Accessing packages on Android 11-Android Developers
Recommended Posts