我想知道如何让它从应用程序中加载可绘制对象或图标及其应用程序名称和活动。我已经查看了许多可用的示例,但不知道如何在这里将它们实现到这个示例中。如果有人可以指导我,那就太好了。
public void loadApps() {
final Intent main=new Intent(Intent.ACTION_MAIN, null);
final PackageManager pm = getPackageManager();
int i=0;
int j=0;
String tmpNick="";
if(pkg.Name.size()!=0 ) {pkg.Name.clear(); pkg.Activity.clear(); pkg.Nick.clear();}
switch(checkedRadioButton) {
case 0:
// LAUCHABLES VARIANT OF LOAD APPS
for(i=0; i<pkgExtra.Name.size(); i++ )
{
pkg.Name.add(pkgExtra.Name.get(i));
pkg.Nick.add(pkgExtra.Nick.get(i));
pkg.Activity.add(pkgExtra.Activity.get(i));
}
main.addCategory(Intent.CATEGORY_LAUNCHER);
final List<ResolveInfo> launchables=pm.queryIntentActivities(main, 0);
for(ResolveInfo launchable : launchables)
{
if (ItemNumInHide(launchable.activityInfo.name)==-1)
{
pkg.Name.add(launchable.activityInfo.packageName);
pkg.Activity.add(launchable.activityInfo.name);
pkg.Nick.add(launchable.activityInfo.loadLabel(pm).toString());
}
}
break;
case 1:
final List<ResolveInfo> launchables2=pm.queryIntentActivities(main, 0);
)
int length=0;
for(ResolveInfo launchable : launchables2)
{
String[] tmpSplit = new String[10];
//acInfo=launchable.activityInfo;
tmpSplit=launchable.activityInfo.name.split("\\.");
length=tmpSplit.length;
pkg.Name.add(launchable.activityInfo.packageName);
pkg.Activity.add(launchable.activityInfo.name);
tmpNick="";
tmpNick=tmpSplit[1];
for(j=2; j<length; j++) {
tmpNick=tmpNick + ":" + tmpSplit[j];
}
pkg.Nick.add(tmpNick);
//pkg.Nick.add(tmpSplit[length-2]+ ":" +tmpSplit[length-1]);
}
break;
case 2:
//final List<ResolveInfo> launchables3=pm.queryIntentActivities(main, 0);
// pkg.last=pkgExtra.Name.size()-1;
for(i=0; i<pkgExtra.Name.size(); i++ )
{
//tmpSplit=acInfo.name.split("\\.");
// length=tmpSplit.length;
pkg.Name.add(pkgExtra.Name.get(i));
pkg.Nick.add(pkgExtra.Nick.get(i));
pkg.Activity.add(pkgExtra.Activity.get(i));
}
break;
case 3:
//pkg.last=pkgHide.Name.size()-1;
for(i=0; i<pkgHide.Name.size(); i++ )
{
//tmpSplit=acInfo.name.split("\\.");
// length=tmpSplit.length;
pkg.Name.add(pkgHide.Name.get(i));
pkg.Nick.add(pkgHide.Nick.get(i));
pkg.Activity.add(pkgHide.Activity.get(i));
}
break;
}
pkg.Name.add(app_package_name+".Menu" );
pkg.Nick.add(" Menu-Launcher");
pkg.Activity.add(app_package_name+".Menu");
}
}