final PackageManager pm = getPackageManager(); List<applicationinfo> packages = pm .getInstalledApplications(PackageManager.GET_Meta_DATA); for (ApplicationInfo packageInfo : packages) { Log.d(TAG,"Installed package :" + packageInfo.packagename); Log.d(TAG,"Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packagename)); }
我试图在列表视图中显示它们,但我有点麻烦.有人可以帮忙吗?
解决方法 这可能对你有所帮助.public class AppList extends Activity { private ListVIEw lVIEw; private ArrayList results = new ArrayList(); @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); lVIEw = (ListVIEw) findVIEwByID(R.ID.List1); PackageManager pm = this.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN,null); intent.addcategory(Intent.category_LAUNCHER); List<ResolveInfo> List = pm.queryIntentActivitIEs(intent,PackageManager.PERMISSION_GRANTED); for (ResolveInfo rInfo : List) { results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString()); Log.w("Installed Applications",rInfo.activityInfo.applicationInfo.loadLabel(pm).toString()); } lVIEw.setAdapter(new ArrayAdapter(this,androID.R.layout.simple_List_item_1,results)); }}总结
以上是内存溢出为你收集整理的如何在列表视图中显示已安装在Android手机上的应用程序列表?全部内容,希望文章能够帮你解决如何在列表视图中显示已安装在Android手机上的应用程序列表?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)