How to get a list of installed android applications and pick one to run

后端 未结 19 1829
误落风尘
误落风尘 2020-11-21 06:26

I asked a similar question to this earlier this week but I\'m still not understanding how to get a list of all installed applications and then pick one to run.

I\'v

19条回答
  •  走了就别回头了
    2020-11-21 07:12

    you can use this :

    PackageManager pm = getApplicationContext().getPackageManager();
                    List activityList = pm.queryIntentActivities(shareIntent, 0);
                    for (final ResolveInfo app : activityList) 
                    {
                       if ((app.activityInfo.name).contains("facebook")) 
                       {
                         // facebook  
                       }
    
                       if ((app.activityInfo.name).contains("android.gm")) 
                       {
                         // gmail  
                       }
    
                       if ((app.activityInfo.name).contains("mms")) 
                       {
                         // android messaging app
                       }
    
                       if ((app.activityInfo.name).contains("com.android.bluetooth")) 
                       {
                         // android bluetooth  
                       }
                    }
    

提交回复
热议问题