当前位置: 代码迷 >> Android >> andriod 取得应用程序名称
  详细解决方案

andriod 取得应用程序名称

热度:424   发布时间:2016-04-24 11:42:00.0
andriod 获得应用程序名称
import android.annotation.TargetApi;import android.app.Activity;import android.app.AlertDialog;import android.content.pm.ApplicationInfo;import android.content.pm.PackageManager;import android.os.Build;import android.os.Bundle;import android.os.Handler;import android.view.MotionEvent;import android.view.View;import android.widget.Toast; 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;    }

 

  相关解决方案