There is a code:

private ArrayAdapter <String> plugins = null; Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List <ResolveInfo> apps = context.getPackageManager().queryIntentActivities(mainIntent, 0); PackageManager pm = context.getPackageManager(); String[] appsList = new String[] { apps.toString() }; plugins = new ArrayAdapter < String > (context, simple_list_item_1.xml, appsList); 

Task: from the application name in appsList [i] find out the name of the package.

    2 answers 2

    Are you sure that in appsList you have application names? Launched for verification, got one long string [ResolveInfo{4056edf8 com.android.mms.ui.ConversationList...] . Accordingly, the question asked has no meaning.

    I believe that you have a fundamentally wrong approach to the task. Personally, I would create my own adapter subclass with the overridden getView() and transfer the list (or an array, not the essence) from ResolveInfo to the adapter immediately. ResolveInfo objects inside contain all the necessary information.

      This method returns the name of your application package .

       getApplicationContext().getPackageName();