2010-04-05 87 views
1

有没有什么办法(编程)找出你的应用程序的名字是什么?我专门谈论从应用程序标签在清单文件中的android:label属性:查找Android应用程序的“名称”

<?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> 
+0

是android:label设置为资源标识符吗?或者它是一个像你的例子中的静态字符串? – 2010-04-05 04:30:03

回答

1

我找到了一种方法来做到这一点...似乎有点迟钝,但:

getPackageManager().getApplicationLabel(getApplicationInfo()) 
0

如果机器人:标签设置为使用字符串资源,如:

<?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> 

然后,你可以这样做:

getString(R.string.app_name) 
相关问题