public class RuanjianmanagerInfo extends Object {
private Drawable icon;//图标
private String name;//标题
private String packname;
private boolean inRom;//是否在内部存储中
private boolean userApp;//是否是系统应用
public Drawable getIcon() {
return icon;
}
public String getName() {
return name;
}
public String getPackname() {
return packname;
}
public boolean isInRom() {
return inRom;
}
public boolean isUserApp() {
return userApp;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public void setName(String name) {
this.name = name;
}
public void setPackname(String packname) {
this.packname = packname;
}
public void setInRom(boolean inRom) {
this.inRom = inRom;
}
public void setUserApp(boolean userApp) {
this.userApp = userApp;
}
}
* 获取某个目录的可用空间
*
* */
private long getAvailabelSpace(String path) {
StatFs statf = new StatFs(path);
statf.getBlockCount();//获取分区的个数
long size = statf.getBlockSize();//获取分区的大小
long count = statf.getAvailableBlocks();//获取可用分区的个数
return size * count;
}
/**
* Created by wofu on 2018/4/25.
* 业务方法,提供手机里面所有安装信息
*/
public class RuanjianManagerInfoProvide {
private static ListruanjianmanagerInfos;
public static ListgetInfos(Context context){
PackageManager pm=context.getPackageManager();
ListpackageInfos=pm.getInstalledPackages(0);
ruanjianmanagerInfos = new ArrayList();
for(PackageInfo packinfo:packageInfos){
//packinfo相当于一个apk包的清单文件
String packname=packinfo.packageName;// 获取包名
Drawable ico=packinfo.applicationInfo.loadIcon(pm);//获取icon
String name=packinfo.applicationInfo.loadLabel(pm).toString();//app名
//判断应用的来源和安装位置
int flags=packinfo.applicationInfo.flags;//应用程序信息标记
if((flags&ApplicationInfo.FLAG_SYSTEM)==0){//用户程序
}else {//系统程序
}
if((flags&ApplicationInfo.FLAG_EXTERNAL_STORAGE)==0){//手机内存
}else {//手机外存储设备
}
RuanjianmanagerInfo info=new RuanjianmanagerInfo();
info.setPackname(packname);
info.setIcon(ico);
info.setName(name);
ruanjianmanagerInfos.add(info);
}
return ruanjianmanagerInfos;
}
}