這個功能在華為手機上測試了,其他機型不確定是不是可以啊。核心的工具類貼出來,列表展示相關的自行編寫。
public class apkinfomanager
public static apkinfomanager getinstance()
}if (resolveinfos != null && resolveinfos.size() > 0) catch (packagemanager.namenotfoundexception e)
if (file.exists())}}
}public listgetresolveinfolist(context context)
/*** @param context
* @param pagename
* @return
*/private long getversioncode(context context, string pagename) else
} catch (exception e)
return 0;
}/**
* @param context
* @param pagename
* @return
*/private string getversion(context context, string pagename) catch (exception e)
return "";
}/**
*/// 獲取應用列表
intent intent = new intent(intent.action_main);
intent.addcategory(intent.category_launcher);
// 排序
@override
public int compare(resolveinfo a, resolveinfo b)
});}
/*** 格式化檔案大小文字
* @param files
* @return
*/private apkinfoentity.filesizeentity filesizefromat(long files) else if (files < 1024 * 1024 * 100) else if (files < 1024 * 1024 * 1000) else if (files < 1024 * 1024 * 1024 * 10l) else if (files < 1024 * 1024 * 1024 * 100l) else if (files < 1024 * 1024 * 1024 * 1000l)
filesizeentity.setfilesize(filesizestring);
filesizeentity.settagsize(tagsize);
return filesizeentity;}}
public class apkinfoentity implements serializable
}public string getpagename()
public void setpagename(string pagename)
public drawable geticondrawable()
public void seticondrawable(drawable icondrawable) }}
}}public string getapkpath()
public void setapkpath(string apkpath)
public string getapksize()
public void setapksize(string apksize)
public static class filesizeentity implements serializable
public void setfilesize(string filesize)
public string gettagsize()
public void settagsize(string tagsize) }}
獲取已安裝應用資訊
首先,我們定義乙個資料結構,來儲存應用程式資訊 icon,name,packagename,versionname,versioncode,等 public string packagename public string versionname public int versioncode 0 p...
iOS 之獲取APP與手機 資訊
nsdictionary infodictionary nsbundle mainbundle infodictionary cfshow cfbridgingretain infodictionary version版本 build版本 手機序列號 nsuuid identifiernumber ...
獲取已安裝apk檔案資訊
眾所周知,通過packagemanager可以獲取手機端已安裝的apk檔案的資訊,具體 如下 packagemanager packagemanager this.getpackagemanager listpackageinfolist packagemanager.getinstalledpac...