0

This is part of my receiver class:

   Uri dataURI = intent.getData();
    String appPackage = (dataURI != null ? dataURI.getSchemeSpecificPart() : null);

    if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
        UpdateUserGamesService.ACTION_PACKAGE_ADDED;
    }
    else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
        UpdateUserGamesService.ACTION_PACKAGE_REMOVED;
    }

Its working well. Is there a way to get the application name and not only the package name?

JY2k
  • 2,879
  • 1
  • 31
  • 60

1 Answers1

0

You can try ApplicationInfo class :

Information you can retrieve about a particular application. This corresponds to information collected from the AndroidManifest.xml's tag.

Try this code to get third party application name :

 List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
    for (int i=0; i < apps.size(); i++)
    {
        if ((apps.get(i).flags & ApplicationInfo.FLAG_SYSTEM) == 1)
        {
              String appName =  (String) getPackageManager().getApplicationLabel(apps.get(i));
             Log.i("App Name", appName);
       }
    }  

Now your question is :

Is it possible to get application name when package is removed ?  

Well i will suggest that get all application name and store it using Persistent Storage (SqLite will be best).

In future if any one removes package still you will have all information related to that application.

I hope this will help.

Piyush Kukadiya
  • 1,880
  • 16
  • 26