public class MyAppInfo { private Drawable image; private String appName; public MyAppInfo(Drawable image, String appName) { this.image = image; this.appName = appName; } public MyAppInfo() { } public Drawable getImage() { return image; } public void setImage(Drawable image) { this.image = image; } public String getAppName() { return appName; } public void setAppName(String appName) { this.appName = appName; } }
只有两个属性,两个构造方法,和系统生成的get ,set方法,没什么好说的,image放置图标,appName放置包名。定义好了放置应用信息的类,接下来再定义一个ApkTool的工具类,用来帮助我们获取当前所安装的App。
/** * Created by gray_dog3 on 16/3/3. * 扫描本地安装的应用,工具类 */ public class ApkTool { static String TAG = "ApkTool"; public static ListmLocalInstallApps = null; public static ListscanLocalInstallAppList(PackageManager packageManager) { ListmyAppInfos = new ArrayList(); try { ListpackageInfos = packageManager.getInstalledPackages(0); for (int i = 0; i