java完成獲得安卓裝備裡已裝置的軟件包。本站提示廣大學習愛好者:(java完成獲得安卓裝備裡已裝置的軟件包)文章只能為提供參考,不一定能成為您想要的結果。以下是java完成獲得安卓裝備裡已裝置的軟件包正文
之前的文章向年夜家引見了幾個項目中經常使用的適用功效,那末在這篇文中,我將向年夜家引見若何獲得Android手機中曾經裝置的手機運用法式,好了,空話不多說,直接上代碼
private String getInstalledAppListAsString(){ PackageManager pm = context.getPackageManager(); List<ApplicationInfo> apps = pm.getInstalledApplications(PackageManager.GET_GIDS); StringBuffer stringBuffer = new StringBuffer(); for (ApplicationInfo app : apps) { if(pm.getLaunchIntentForPackage(app.packageName) != null) { // apps with launcher intent if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) { // updated system apps } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) { // system apps } else { // user installed apps stringBuffer.append(app.packageName).append(';'); } } } return stringBuffer.toString(); }
上面我們看看詳細若何獲得各個運用的相干信息呢
package cn.lyz.mobilesafe.domain; import android.graphics.drawable.Drawable; /** * 獲得的運用根本信息實體類 * @author liuyazhuang * */ public class AppInfo { //圖標 private Drawable app_icon; //運用稱號 private String app_name; //運用版本號 private String app_version; //運用包名 private String packagename; //能否是用戶app private boolean isUserApp; public AppInfo() { super(); // TODO Auto-generated constructor stub } public AppInfo(Drawable app_icon, String app_name, String app_version, String packagename) { super(); this.app_icon = app_icon; this.app_name = app_name; this.app_version = app_version; this.packagename = packagename; } public AppInfo(Drawable app_icon, String app_name, String app_version, String packagename, boolean isUserApp) { super(); this.app_icon = app_icon; this.app_name = app_name; this.app_version = app_version; this.packagename = packagename; this.isUserApp = isUserApp; } public Drawable getApp_icon() { return app_icon; } public void setApp_icon(Drawable app_icon) { this.app_icon = app_icon; } public String getApp_name() { return app_name; } public void setApp_name(String app_name) { this.app_name = app_name; } public String getApp_version() { return app_version; } public void setApp_version(String app_version) { this.app_version = app_version; } public String getPackagename() { return packagename; } public void setPackagename(String packagename) { this.packagename = packagename; } public boolean isUserApp() { return isUserApp; } public void setUserApp(boolean isUserApp) { this.isUserApp = isUserApp; } @Override public String toString() { return "AppInfo [app_icon=" + app_icon + ", app_name=" + app_name + ", app_version=" + app_version + ", packagename=" + packagename + ", isUserApp=" + isUserApp + "]"; } }