你的位置:首页 > 操作系统

[操作系统]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;  }