最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android獲取應(yīng)用程序名稱(ApplicationName)示例

 更新時(shí)間:2013年06月20日 15:31:26   作者:  
本文以實(shí)例方式為大家介紹下獲取應(yīng)用程序名稱(ApplicationName)的具體實(shí)現(xiàn),感興趣的各位可以參考下哈
MainActivity如下:
復(fù)制代碼 代碼如下:

package cn.testapplicationname;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
/**
* Demo描述:
* 獲取應(yīng)用程序名稱(ApplicationName)
*/
public class MainActivity extends Activity {
private TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
}
private void init() {
mTextView = (TextView) findViewById(R.id.textView);
String applicationName = getApplicationName();
mTextView.setText("該應(yīng)用名字:"+applicationName);
}
public String getApplicationName() {
PackageManager packageManager = null;
ApplicationInfo applicationInfo = null;
try {
packageManager = getApplicationContext().getPackageManager();
applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
applicationInfo = null;
}
String applicationName =
(String) packageManager.getApplicationLabel(applicationInfo);
return applicationName;
}
}

main.xml如下:
復(fù)制代碼 代碼如下:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:layout_centerInParent="true"
/>
</RelativeLayout>

相關(guān)文章

最新評(píng)論

星座| 新泰市| 隆尧县| 格尔木市| 岱山县| 德昌县| 万山特区| 镇雄县| 满洲里市| 郯城县| 通许县| 双鸭山市| 益阳市| 逊克县| 陵川县| 西吉县| 惠东县| 交城县| 图片| 苍溪县| 舟山市| 元氏县| 巫山县| 阿拉善盟| 肥乡县| 邹城市| 陈巴尔虎旗| 巴林左旗| 普定县| 巴林右旗| 连山| 亳州市| 霸州市| 乐山市| 和政县| 冷水江市| 宁武县| 临清市| 曲麻莱县| 临沧市| 芜湖市|