最新国产好看的视频,伊人天堂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)論

稷山县| 呼图壁县| 忻州市| 平顶山市| 南涧| 水城县| 永福县| 江津市| 武冈市| 宁波市| 东明县| 高密市| 怀远县| 弥渡县| 沧州市| 开平市| 如皋市| 泸西县| 夏河县| 洪雅县| 闸北区| 丰都县| 集安市| 中江县| 达拉特旗| 惠来县| 资中县| 佛冈县| 库尔勒市| 庐江县| 武平县| 宿松县| 增城市| 崇义县| 高阳县| 永川市| 山东省| 娄烦县| 光泽县| 西乌珠穆沁旗| 峨眉山市|