Check phone for installed app?


  1. pizzato16

    pizzato16 New Member

    Im putting together an app that has a function requiring an outside app to be downloaded ( if the user doesnt already have it) my question is, how would I code the activity to search the users phone for the installed app before auto downloading it? I dont want them to have to repeatedly download the app if its already on their phone. Thanks.

    Advertisement
    :
  2. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Should be able to use this to see what is installed and compare the package name against what you're looking for
    Code (Text):
    1.  
    2. PackageManager pm = getPackageManager();                
    3. List<ApplicationInfo> list = pm.getInstalledApplications(0);
    4.                
    5. for (int i=0; i< list.size(); i++)
    6. {
    7.     ApplicationInfo appInfo = list.get(i);
    8.     String packageName = appInfo.packageName;
    9.     String appLabel = (String) pm.getApplicationLabel(appInfo);
    10.     Drawable icon = pm.getApplicationIcon(appInfo);
    11. }
    12.  
Loading...

Share This Page