Hi Friends, if you like my blog please give your valuable comments it will help to improve my blog content and enthusiasm to write a lot in android World.

Thursday, November 29, 2012

Get list of currently installed apps

List out all of the user's installed applications in an activity. 
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));
}

No comments:

Post a Comment