i'm writing an android module, which i will include in some of my projects. Now i need to get the application name(at runtime), e.g. the name that is set as android:label
for the application in the manifest. Obviously i can't use getResources().getString(R.string.app_name)
because i can't access the resources of the project that uses this library. Is there another way?
I tried getApplicationInfo().name
but that is null
and i can't find anything else.
You can find an app's package name in the URL of your app's Google Play Store listing. For example, the URL of an app page is play.google.com/store/apps/details? id=com.
As I mentioned, the Play Store also uses the Android app package name to list unique apps. So, the easiest way to find the app package name is via the Play Store.
One method to look up an app's package name is to find the app in the Google Play app store using a web browser. The package name will be listed at the end of the URL after the '? id='. In the example below, the package name is 'com.google.android.gm'.
Module Name: This text is used as the name of the folder where your source code and resources files are visible. Package Name: This is the Java namespace for the code in your module. It is added as the package attribute in the module's Android manifest file.
I tried getApplicationInfo().name but that is null
That is because name
comes from the android:name
attribute on <application>
, and you are not using a custom Application
subclass in your app.
i can't find anything else.
Call loadLabel()
on the ApplicationInfo
, passing in a PackageManager
as a parameter, to retrieve the android:label
value for an <application>
or any component (e.g., <activity>
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With