tags:

views:

83

answers:

2

Is there any way to (programatically) find out what your app's name is? I'm specifically talking about the android:label property from the application tag in the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test" android:versionCode="1" android:versionName="1.0">
    <application android:label="THIS THING HERE!" android:icon="@drawable/icon">
        <!-- ... -->
    </application>
</manifest> 
+1  A: 

I found a way to do it... seems a little obtuse though:

getPackageManager().getApplicationLabel(getApplicationInfo())
fiXedd
A: 

If android:label is set to use a string resource such as:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test" android:versionCode="1" android:versionName="1.0">
    <application android:label="@string/app_name" android:icon="@drawable/icon">
        <!-- ... -->
    </application>
</manifest> 

Then you can do:

getString(R.string.app_name)
Joshua Rodgers