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!

4

1 回答 1

0

这是我用来获取应用程序名称、标签、图标和包名称的代码

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);

            }

使用它,我们可以获得用户安装和使用的所有应用程序

于 2013-09-20T05:14:55.207 回答