得到DeviceId:
来源:互联网 发布:中国未来发展 知乎 编辑:程序博客网 时间:2024/05/22 15:52
public static String getDeviceId(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());
String uniqueId = deviceUuid.toString();
return uniqueId;
}
/**
* 获取设备UUID
*
* @param context
* @return
*/
public static 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());
String uniqueId = deviceUuid.toString();
Log.d("debug", "uuid=" + uniqueId);
return uniqueId;
}
public static String getAppVersionName(Context context) {
String versionName = "";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
versionName = pi.versionName;
if (versionName == null || versionName.length() <= 0) {
return "";
}
} catch (Exception e) {
}
return versionName;
}
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());
String uniqueId = deviceUuid.toString();
return uniqueId;
}
/**
* 获取设备UUID
*
* @param context
* @return
*/
public static 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());
String uniqueId = deviceUuid.toString();
Log.d("debug", "uuid=" + uniqueId);
return uniqueId;
}
public static String getAppVersionName(Context context) {
String versionName = "";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
versionName = pi.versionName;
if (versionName == null || versionName.length() <= 0) {
return "";
}
} catch (Exception e) {
}
return versionName;
}
- 得到DeviceId:
- android deviceId
- 独一无二的DeviceId
- Google Play 之 deviceId
- android 获取deviceID
- android_id和deviceId
- keygoe摘要--deviceID
- 遍历OLT DeviceID
- Android - 设备的DeviceId
- token和deviceId
- CocosCreator android 获取deviceId
- 修改genymotion的deviceId
- Android的DeviceID的添加
- Android的DeviceID的添加
- worklight获取设备的deviceID
- iOS 获取deviceid的方法
- android手机查看设备ID,deviceID
- Zigbee中的PANID,CHANNEL,DEVICEID功能
- 第一次创业还是失败了---分享失败的经验!!!
- AES-128 加密算法
- hdu 4527 ——小明系列故事——玩转十滴水
- php通过gmtime()获取的时间戳,格式化后与系统时间不一致
- bootanimation
- 得到DeviceId:
- window一个文件夹中最多可以存储多少个文件
- JS中DIV随鼠标移动的事件
- 颜色收集
- C++局部类作用域的说明
- Udacity调试课笔记之简化失败
- android工程师常见招聘需求
- 黑马程序员--Java基础学习之网络编程(TCP、UDP、Socket、模拟发送和接收数据)
- 红外接收头TSOP34838连续通信能力