Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the name of the application in android?

Tags:

android

I want to get the name of my application. How can i get that? Thanks in advance.

like image 371
Prachi Avatar asked Oct 18 '11 05:10

Prachi


People also ask

How do you get an app name?

Find an Android app nameGo to the Google Play Store for Apps. Search by app name. Click the result for your app.

Where can I find Android app ID?

Android. We use the Application ID (package name) to identify your app inside our system. You can find this in the app's Play Store URL after 'id'. For example, in https://play.google.com/store/apps/details?id=com.company.appname the identifier would be com.

What is the file named in case of Android app?

The Android Package with the file extension apk is the file format used by the Android operating system, and a number of other Android-based operating systems for distribution and installation of mobile apps, mobile games and middleware. It can be written in either Java or Kotlin.


1 Answers

You can use PackageItemInfo -> nonLocalizedLabel to get application name.

val applicationName = context.applicationInfo.nonLocalizedLabel.toString()

[Old Answer]

Usually, we do add the application name with app_name string resource, so you can write below code to access the app name

String applicationName = getResources().getString(R.string.app_name);

Reference : Resource Types

But note that, this resource name is not mandatory and can be changed to any other string name. In that case, the code will not work. See the first code snippet which uses PackageItemInfo -> nonLocalizedLabel above for a better solution.

like image 169
Pankaj Kumar Avatar answered Oct 07 '22 15:10

Pankaj Kumar