Android獲得當前安裝的所有應用程序列表
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));
} </pre>
本文由用戶 c6b4 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!