且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获得安装在Android手机的所有应用程序

更新时间:2022-12-30 08:42:28

这code日志名称和包的所有安装的应用程序名称。你可以很容易地检查使用LogCat中(如果你使用的是Eclipse)的日志。

This code logs name and package name of all the installed applications. You can easily check the log using LogCat (if you are using Eclipse).

包名称 - 应用程序的软件包的名称

Package name - name of the app's package.

名称 - 与应用程序相关的文本标签。你不能只使用 appInfo.name ,因为它会返回。使用 appInfo.loadLabel(packageManager)你得到实际的应用程序的名称,比如语音记录器的,而不是包名的 com.android.speechrecorder

Name - text label associated with the application. You can't use just appInfo.name as it will return null. Using appInfo.loadLabel(packageManager) you get the actual app's name like Speech Recorder instead of package name com.android.speechrecorder.

final PackageManager packageManager = getPackageManager();
List<ApplicationInfo> installedApplications = 
   packageManager.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo appInfo : installedApplications)
{
    Log.d("OUTPUT", "Package name : " + appInfo.packageName);
    Log.d("OUTPUT", "Name: " + appInfo.loadLabel(packageManager));
}