5

I'm trying to develop an android app that could list all app's which has cache, I successfully got the information about cache, but now I want to display those app which has some cache in the screen, I have the package name, but problem is how to get the application name from package name,

Let's say package name is com.android.browser then app name will be Browser

How to achieve this task ?

Please don't mind if this question is silly to you, please help me in solving this riddle, Thanks in advance.

Chethan Shetty
  • 1,972
  • 4
  • 25
  • 45
  • Possible duplicate of [get application name from package name](http://stackoverflow.com/questions/5841161/get-application-name-from-package-name) – mixel Jan 19 '17 at 12:00

2 Answers2

15

You need to use PackageManager to get detailed information about installed packages.

PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo = null;
try {
    applicationInfo = packageManager.getApplicationInfo(packageName, 0);
} catch (final NameNotFoundException e) {}
final String title = (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
JRomero
  • 4,878
  • 1
  • 27
  • 49
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

Try to use PackageManager#getActivityInfo(); There is field which contain app name.

Siddharth
  • 9,349
  • 16
  • 86
  • 148
adek
  • 3,045
  • 2
  • 27
  • 41
  • How do you initialse PackageManager to your defined package name, let's say `com.android.browser` how will you initialse `PackageManager` to our own package @adek – Chethan Shetty Jul 05 '13 at 13:54