if (className.equals(mServiceList.get(i).service.getClassName())) {
return true;
}
}
return false;
}
判断是否安装了某个软件
public static boolean isInstall(Context cont, String packName) {
PackageManager packageManager = cont.getPackageManager();
List list = packageManager
.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo packageInfo : list) {
if (packageInfo.packageName.equals(packName)) {
return true;
}
}
return false;
}
获取手机串号唯一标示
public static String getMIEI(Context context) {
String MIEI;
TelephonyManager telephonemanage = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
try {
MIEI = telephonemanage.getDeviceId();
return MIEI;
} catch (Exception e) {
Log.i("error", e.getMessage());
return null;
}
}
获取版本
public static int getVersionCode(Context context) throws Exception {
PackageManager packageManager = context.getPackageManager();
PackageInfo packInfo = packageManager.getPackageInfo(
context.getPackageName(), 0);
int version = packInfo.versionCode;
return version;
}
获取手机内所有应用
public static List getAllApps(Context context) {
List apps = new ArrayList();
PackageManager pManager = context.getPackageManager();
// 获取手机内所有应用
List paklist = pManager.getInstalledPackages(0);
for (int i = 0; i PackageInfo pak = (PackageInfo) paklist.get(i);
// 判断是否为非系统预装的应用程序
if ((pak.applicationInfo.flags & pak.applicationInfo.FLAG_SYSTEM) <&#61; 0) {
// customs applications
apps.add(pak);
}
}
return apps;
}
通过包名获取Apk名字
public static String getApkName(Context context, String packeName) {
PackageManager pManager &#61; context.getPackageManager();
List appList &#61; getAllApps(context);
for (int i &#61; 0; i if (appList.get(i).packageName.equals(packeName)) {
return pManager.getApplicationLabel(
appList.get(i).applicationInfo).toString();
}
}
return null;
}
判断手机GPS是否开启
public static boolean gpsIsOpen(Context context) {
LocationManager alm &#61; (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
return true;
}
return false;
}
判断是手机品牌
public static boolean isHTC() {
String MODEL &#61; android.os.Build.MODEL;
if (MODEL.contains("HTC")) {
return true;
} else
return false;
}
设置手机系统亮度
public static void setSystemLight(Activity activity, int light) {
ContentResolver cr &#61; activity.getContentResolver();
Settings.System.putInt(cr, "screen_brightness", light);
Window window &#61; activity.getWindow();
LayoutParams attributes &#61; window.getAttributes();
float flevel &#61; light;
attributes.screenBrightness &#61; flevel / 255;
float x &#61; attributes.screenBrightness;
activity.getWindow().setAttributes(attributes);
}