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.

1

2 Answers 2

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) : "???");
Sign up to request clarification or add additional context in comments.

7 Comments

In the first approach getApplicationName you passed Context as parameter, but actually I want to get name of other app from my app, that means Context will be different right, then if we execute int stringId = context.getApplicationInfo().labelRes; we will get our present app id
Oh you removed first approach ?
I did as it was not answering your question
Ok Thanks @Marcin Orlowski for your time. But unfortunately this approach is not working.
what is not working? This will return application name (label) as set in app manifest
|
0

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

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.