按照下面的代码运行,就会获得已经安装的程序列表
1
2
3
|
final
Intent mainIntent = new
Intent(Intent.ACTION_MAIN, null ); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final
List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent,
0 ); |
或者下面链接和代码也
Link: http://www.androidsnippets.com/get-installed-applications-with-name-package-name-version-and-icon
Here a good example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
class
PInfo { private
String appname = "" ; private
String pname = "" ; private
String versionName = "" ; private
int
versionCode = 0 ; private
Drawable icon; private
void
prettyPrint() { Log.v(appname
+ "\t"
+ pname + "\t"
+ versionName + "\t"
+ versionCode); } } private
ArrayList<pinfo> getPackages() { ArrayList<pinfo>
apps = getInstalledApps( false );
/*
false = no system packages */ final
int
max = apps.size(); for
( int
i= 0 ;
i<max; arraylist<pinfo= ""
private = ""
}= ""
apps;= ""
return = ""
apps.get(i).prettyprint();= ""
{= ""
i++)= "" >
getInstalledApps( boolean
getSysPackages) { ArrayList<pinfo>
res = new
ArrayList<pinfo>(); List<packageinfo>
packs = getPackageManager().getInstalledPackages( 0 ); for ( int
i= 0 ;i<packs.size();i++)
}= ""
return = ""
{= ""
pre= ""
<= ""
res;= ""
res.add(newinfo);= ""
newinfo.icon= "p.applicationInfo.loadIcon(getPackageManager());"
newinfo.versioncode= "p.versionCode;"
newinfo.versionname= "p.versionName;"
newinfo.pname= "p.packageName;"
newinfo.appname= "p.applicationInfo.loadLabel(getPackageManager()).toString();"
pinfo();= ""
newinfo= "new"
pinfo= ""
;= ""
continue = ""
null ))= ""
(p.versionname= "="
&&= ""
((!getsyspackages)= ""
if = ""
p= "packs.get(i);"
packageinfo= "" ></packs.size();i++)></packageinfo></pinfo></pinfo></max;></pinfo></pinfo> |
原文地址:http://www.itmmd.com/201411/122.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
原文地址:http://blog.csdn.net/androidmylove/article/details/42078711