0

I'm trying to make an app that will show selected app in a list view. I found this link How to get a list of installed android applications and pick one to run but it only show all the app installed on the device. All I want to show is all the app that I made that I installed on my device. So I wonder if I can select them one by one using package name or app name and then put it on a list view using package manager?

Any thoughts will be appreciated.

Community
  • 1
  • 1
Gangnaminmo Ako
  • 567
  • 10
  • 27

1 Answers1

1

This is what you can do, filter package containing your package name:

    List<PackageInfo> packs = context.getPackageManager() 
            .getInstalledPackages(0); 

    public static final String MY_APP_PATTERN="com.myapps";

    for (int i = 0; i < packs.size(); i++) { 
        PackageInfo packageInfo = packs.get(i); 
        if (((packs.get(i).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) { 
            continue; 
        } 

       if(packageInfo.packageName.contains(MY_APP_PATTERN)){
           Lod.d(DEBUG_TAG,"This package belongs to me: "+packageInfo.packageName)

           packageInfo.applicationInfo.loadLabel( 
                context.getPackageManager()).toString(); 
           packageInfo.packageName; 
           packageInfo.versionCode; 
           packageInfo.applicationInfo.loadIcon(context 
                .getPackageManager())
       }
    } 

You can also use your own pattern matcher to filter starting with.

Milan
  • 1,767
  • 5
  • 18
  • 33