繁体   English   中英

列出已安装的Android应用

[英]List out the installed apps android

如何获取已下载的已安装应用程序,而不是下载的应用程序(如联系人,设置,相机等)。 我正在使用PackageManager,它返回整个应用程序(默认+下载)。

尝试这个:

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 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));
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM