一、获取APP名字、图标、版本等信息
/** 获取单个App图标 **/
public Drawable getAppIcon(String packageName) throws NameNotFoundException {
Drawable icon = pManager.getApplicationIcon(packageName);
return icon;
}
/** 获取单个App名称 **/
public String getAppName(String packageName) throws NameNotFoundException {
ApplicationInfo appInfo = pManager.getApplicationInfo(packageName, 0);
String appName = pManager.getApplicationLabel(appInfo).toString();
return appName;
}
/** 获取单个App版本号 **/
public String getAppVersion(String packageName) throws NameNotFoundException {
PackageInfo packageInfo = pManager.getPackageInfo(packageName, 0);
String appVersion = packageInfo.versionName;
return appVersion;
}
/** 获取单个App的所有权限 **/
public String[] getAppPermission(String packageName) throws NameNotFoundException {
PackageInfo packageInfo = pManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
String[] permission = packageInfo.requestedPermissions;
return permission;
}
/** 获取单个App的签名 **/
public String getAppSignature(String packageName) throws NameNotFoundException {
PackageInfo packageInfo = pManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
String allSignature = packageInfo.signatures[0].toCharsString();
return allSignature;
}
二、获取Android版本信息
int currentVersion = android.os.Build.VERSION.SDK_INT;
android.os.Build的其他属性输出如下,笔者的手机是小米4:
VERSION.SDK_INT--------->19
VERSION.SDK--------->19
VERSION.CODENAME--------->REL
VERSION.INCREMENTAL--------->5.8.27
VERSION.RELEASE--------->4.4.4
VERSION_CODES.JELLY_BEAN--------->16
BOARD--------->MSM8974
BOOTLOADER--------->unknown
BRAND--------->Xiaomi
CPU_ABI--------->armeabi-v7a
CPU_ABI2--------->armeabi
DEVICE--------->cancro
DISPLAY--------->KTU84P
FINGERPRINT--------->Xiaomi/cancro_wc_lte/cancro:4.4.4/KTU84P/5.8.27:user/release-keys
HARDWARE--------->qcom
HOST--------->qh-miui-ota-bd58
ID--------->KTU84P
MANUFACTURER--------->Xiaomi
MODEL--------->MI 4LTE
PRODUCT--------->cancro_wc_lte
RADIO--------->unknown
SERIAL--------->a4a0d854
TAGS--------->release-keys
TIME--------->1440624955000
TYPE--------->user
UNKNOWN--------->unknown
USER--------->builder
getRadioVersion()--------->MPSS.DI.3.0-d354d78