android 获取另一个apk的信息
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 08:07 点击:次
/**
* @return all local plaugins
*/
private List<PlauginInfo> findLocalPlugins(){
PackageManager pm=getPackageManager();
//List<PackageInfo> pkgs=pm.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
Intent mainIntent = new Intent("com.android.uxun", null);
List<ResolveInfo> allApps=getPackageManager().queryIntentActivities(mainIntent, 0);
Log.i(TAG, "======allApps.size()==="+allApps.size());
sLoaclPlugins.clear();
for(ResolveInfo resolveInfo:allApps){
String packageName=resolveInfo.activityInfo.packageName;
ApplicationInfo applicationInfo=resolveInfo.activityInfo.applicationInfo;
String label=pm.getApplicationLabel(applicationInfo).toString();
PlauginInfo plug=new PlauginInfo();
Context context=null;
try {
context = createPackageContext(packageName,Context.CONTEXT_IGNORE_SECURITY);
if(context!=null){
plug.classId=context.getSharedPreferences("plaugin",MODE_WORLD_READABLE+MODE_WORLD_WRITEABLE).getInt("plauginId",0);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.description="";
Drawable drawable=pm.getApplicationIcon(applicationInfo);
if(drawable!=null){
plug.icon=((BitmapDrawable)drawable).getBitmap();
}
plug.intent=new Intent(packageName);
plug.itemType=0;
plug.openCount=0;
plug.postFlag=0;
plug.title=label;
int versionCode=0;
try {
versionCode = pm.getPackageInfo(packageName,0).versionCode;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.versionId=versionCode;
sLoaclPlugins.add(plug);
}
/*for(PackageInfo pkg :pkgs){
if("android.uxun".equals(pkg.sharedUserId)){
String packageName=pkg.packageName;
//String prcessName=pkg.applicationInfo.processName;
String label=pm.getApplicationLabel(pkg.applicationInfo).toString();
PlauginInfo plug=new PlauginInfo();
Context context=null;
try {
context = createPackageContext(packageName,Context.CONTEXT_IGNORE_SECURITY);
if(context!=null){
plug.classId=context.getSharedPreferences("plaugin",MODE_WORLD_READABLE+MODE_WORLD_WRITEABLE).getInt("plauginId",0);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.description="";
Drawable drawable=pm.getApplicationIcon(pkg.applicationInfo);
* @return all local plaugins
*/
private List<PlauginInfo> findLocalPlugins(){
PackageManager pm=getPackageManager();
//List<PackageInfo> pkgs=pm.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
Intent mainIntent = new Intent("com.android.uxun", null);
List<ResolveInfo> allApps=getPackageManager().queryIntentActivities(mainIntent, 0);
Log.i(TAG, "======allApps.size()==="+allApps.size());
sLoaclPlugins.clear();
for(ResolveInfo resolveInfo:allApps){
String packageName=resolveInfo.activityInfo.packageName;
ApplicationInfo applicationInfo=resolveInfo.activityInfo.applicationInfo;
String label=pm.getApplicationLabel(applicationInfo).toString();
PlauginInfo plug=new PlauginInfo();
Context context=null;
try {
context = createPackageContext(packageName,Context.CONTEXT_IGNORE_SECURITY);
if(context!=null){
plug.classId=context.getSharedPreferences("plaugin",MODE_WORLD_READABLE+MODE_WORLD_WRITEABLE).getInt("plauginId",0);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.description="";
Drawable drawable=pm.getApplicationIcon(applicationInfo);
if(drawable!=null){
plug.icon=((BitmapDrawable)drawable).getBitmap();
}
plug.intent=new Intent(packageName);
plug.itemType=0;
plug.openCount=0;
plug.postFlag=0;
plug.title=label;
int versionCode=0;
try {
versionCode = pm.getPackageInfo(packageName,0).versionCode;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.versionId=versionCode;
sLoaclPlugins.add(plug);
}
/*for(PackageInfo pkg :pkgs){
if("android.uxun".equals(pkg.sharedUserId)){
String packageName=pkg.packageName;
//String prcessName=pkg.applicationInfo.processName;
String label=pm.getApplicationLabel(pkg.applicationInfo).toString();
PlauginInfo plug=new PlauginInfo();
Context context=null;
try {
context = createPackageContext(packageName,Context.CONTEXT_IGNORE_SECURITY);
if(context!=null){
plug.classId=context.getSharedPreferences("plaugin",MODE_WORLD_READABLE+MODE_WORLD_WRITEABLE).getInt("plauginId",0);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
plug.description="";
Drawable drawable=pm.getApplicationIcon(pkg.applicationInfo);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>