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">
开发者_StackOverflow中文版 <!-- ... -->
</application>
</manifest>
I found a way to do it... seems a little obtuse though:
getPackageManager().getApplicationLabel(getApplicationInfo())
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)
精彩评论