Monday, April 5, 2010

Retrieve Application Names

Here the following code snippet used to retrieve the installed package in your device

  ListView programsList;
   PackageManager mPackageManager;
 

   programsList = (ListView) findViewById(R.id.ListView01);
    programsList.setTextFilterEnabled(true);
    mPackageManager = getPackageManager();
    List<String> packageName = new ArrayList<String>(); 
    List<ResolveInfo> list = mPackageManager.queryIntentActivities(
        new Intent(Intent.ACTION_MAIN), 0);
    for (ResolveInfo r : list) {
        packageName.add(r.loadLabel(mPackageManager).toString());
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,  
    packageName);
    programsList.setAdapter(adapter);



No comments:

Post a Comment