手机特定信息获取
来源:互联网 发布:域名被腾讯封了怎么办 编辑:程序博客网 时间:2024/05/07 17:05
获取设备IMEI
/** * 获取设备IMEI。 * @param context 应用程序上下文对象。 * @return 设备IMEI。 */ public static String getIMEI(Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imei = tm.getDeviceId(); if (!isEmpty(imei)) { return imei; } else { // 获取mac地址。 WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiMan != null) { WifiInfo wifiInf = wifiMan.getConnectionInfo(); if (wifiInf != null && wifiInf.getMacAddress() != null) { // 48位,如FA:34:7C:6D:E4:D7。 imei = wifiInf.getMacAddress().replaceAll(":", ""); return imei; } } } return ""; }
获取设备UUID,由设备信息产生
/** * 获取设备UUID,由设备信息产生。 * @return 设备UUID。 */ public static final String getUUID(Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid.toString(); }
手机机主名称。
/** * 手机机主名称。 * @return 机主名称。 */ public static final String getName() { String name = android.os.Build.USER; if (isEmpty(name)) { name = null; } return name; }
基础信息获取
/** * 获取手机操作系统版本号。 * @return 手机操作系统版本号 */ public static final String getVersion() { return android.os.Build.VERSION.RELEASE; } /** * <p> * 当前系统平台。 * </p> * * @return "Android" */ public static final String getPlatform() { return "Android"; } /** * 获取sdk版本。 * @return 手机的sdk版本。 */ public static final int getSDKVersion() { return android.os.Build.VERSION.SDK_INT; } /** * 获取手机型号。 * @return 手机型号。 */ public static final String getModel() { return android.os.Build.MODEL; } /** * 获取手机的设备名称。 * @return 手机设备名称字符串。 */ public static final String getPhoneTarget() { String temp = android.os.Build.DEVICE; temp = temp.replace(" ", "").replace("-", "_").trim(); return temp; } /** * 获取设备ID。 * @return 设备名称id。 */ public static final String getClientID() { String temp = android.os.Build.ID; temp = temp.replace(" ", "").replace("-", "_").trim(); return temp; }
/** * 查看android手机是否被刷过机.linux系统下root权限可以使用su命令,android本身也是小型的linux系统。 * @param command "id" 或其他的 su命令。 */ public static final boolean runRootCommand(String command) { Process process = null; DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); int exitValue = process.waitFor(); if (exitValue == 0) { return true; } else { return false; } } catch (Exception e) { printException(e); return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { // nothing } } } /** * <p> * 判断是否root * </p> * <p> * */public static boolean isJailBroken(){ boolean result = Utils.runRootCommand("echo test"); return result; }
0 0
- 手机特定信息获取
- 针对获取手机上的一些特定信息的工具类
- 获取手机信息
- Android 获取手机信息
- android 获取手机信息
- 获取手机设备信息
- 获取android手机信息
- 获取手机IMEI信息
- android 获取手机信息
- android获取手机信息
- android 获取手机信息
- 获取android手机信息
- android 手机信息获取
- Android获取手机信息
- android 获取手机信息
- android获取手机信息
- Android 获取手机信息
- Android 获取手机信息
- Android 手机听筒Earpiece和扬声器speaker切换
- 由无序数组中找到第K 大的元素
- xp里如何不用重启切换用户名访问服务器
- 学习总结连载一
- python time模块详解
- 手机特定信息获取
- MYSQL查询
- TCP连接中TIME_WAIT连接过多
- android 比较靠谱的图片压缩
- Spark 伪分布式 & 全分布式 安装指南
- linux 出行日记(3)
- Turkey Burgers with Smashed Avocado and Pickles
- C# SQLiteHelper类似SqlHelper类实现存取Sqlite数据库
- 用SecureCRT上传下载文件(SSH协议)