0

I am developing an Android application wherein I am trying to check whether an application has been already installed in the device or not. I am fetching the application info using below code. For example to check whether google maps is installed or not, I am using its package name as shown below.

        ApplicationInfo info1 = getPackageManager().
        getApplicationInfo("com.google.android.apps.maps", 0 );

My question is , if at all this package name is changed by google in future, I will have to update the package name and then send an update to users... Other than checking from package name - Is there any other way to get to know if an application is installed or not?

Kindly Help! Thanks!

TheDevMan
  • 5,914
  • 12
  • 74
  • 144
sanjana
  • 641
  • 2
  • 15
  • 36
  • For an app the package name cannot change. If you change the package name then its a new app. It cant be the same app. – Tarun Sep 20 '13 at 09:51

1 Answers1

0

This is the code which i use to get app name,lable, icon and package name

Intent intent = new Intent("android.intent.action.MAIN");
            intent.addCategory("android.intent.category.LAUNCHER");
            PackageManager manager = getPackageManager();
            List<ResolveInfo> resolveinfo_list = manager.queryIntentActivities(intent, 0);

            for(ResolveInfo info:resolveinfo_list){

                    //launchComponent(info.activityInfo.packageName, info.activityInfo.name);
                    String lActTitle = (String) info.loadLabel(manager);
                    Drawable d = info.activityInfo.loadIcon(manager);


                    System.out.println("info.activityInfo.packageName>>>>>>>>>>>>>>>" + info.activityInfo.packageName);
                    System.out.println("info.activityInfo.name>>>>>>>>>>>>>>>" + info.activityInfo.name);
                    System.out.println("info.activityInfo.name>>>>>>>>>>>>>>>" + info.activityInfo.name);

                   // RowItem item = new RowItem(d,info.activityInfo.packageName,lActTitle,info.activityInfo.name);
                   //rowItems.add(item);

            }

Using this we can get all the app which is installed and used by user

Dhaval Patel
  • 694
  • 4
  • 12
  • But before that , i want to check if the application has already been installed in the device or not. – sanjana Sep 20 '13 at 06:00
  • here you get the information of all app which is only installed to user device – Dhaval Patel Sep 20 '13 at 06:01
  • add all package name to a list and check your app pkg name is avilable or not if pkg name is available then app is installed otherwise not........ – Dhaval Patel Sep 20 '13 at 06:07
  • Other than checking from package name - Is there any other way to get to know if an application is installed or not? – sanjana Sep 20 '13 at 10:14
  • I think this link is useful for you.........http://stackoverflow.com/questions/11392183/how-to-check-if-the-application-is-installed-or-not-in-android-programmatically – Dhaval Patel Sep 20 '13 at 10:19