0

I tried getting the name of other application from its package name from the code given in

Android: Get application name (not package name)

But for some application, it is giving different name. eg.

for "Phone" app, it is giving "Google dialer"

for "Play store" app, it is giving "Google play store".

I understand that "Google dialer" is the application label and hence it is giving that, but is there a way to get application name as presented in the Google default launcher. (Get "Phone" instead of "Google dialer".)

Community
  • 1
  • 1
user2436032
  • 365
  • 1
  • 4
  • 13

1 Answers1

0

Just do:

    public static String getApplicationName(Context context) {
    int stringId = context.getApplicationInfo().labelRes;
    return context.getString(stringId);
}

Hope this helps.

Hitesh Singh
  • 1,951
  • 1
  • 10
  • 15
  • I want the app name for other apps . I think, the above code will give me the app name of the current application. Please correct me if I am wrong. – user2436032 Apr 30 '15 at 11:00
  • not getting you please elaborate more about your requirement. – Hitesh Singh Apr 30 '15 at 11:05
  • In android, we can get the list of all the installed application via the package manager. I want their names(of all applications). So I tried the code http://stackoverflow.com/questions/11229219/android-get-application-name-not-package-name , but it is giving me a different name for a few apps. So I was wondering, how to get app names as appear in the google now launcher. – user2436032 Apr 30 '15 at 11:08
  • Please check [this](http://theopentutorials.com/tutorials/android/listview/how-to-get-list-of-installed-apps-in-android/) it will help you. Thanks – Hitesh Singh Apr 30 '15 at 11:15
  • Thanks, I am doing the exact same thing , but the code `String appName = packageManager.getApplicationLabel( packageInfo.applicationInfo).toString();` is taking the label of the application which in case of the Phone application is "Google dialer", but I need is appName = "Phone" , so the given code is not what I am looking for. – user2436032 Apr 30 '15 at 11:26