IMEI 是否适用于所有 Android 设备?不能篡改吗?
Is IMEI available on all Android devices? Can it not be tampered?
我正在与一些联盟营销公司合作,我需要通过他们推广我的 android 应用程序,但为此我需要检查我的应用程序的安装是否是独一无二的。我需要为每次安装提供一些金额,为了正确地做到这一点,我需要确定安装是否是唯一的,如果是唯一的则只放款,否则不放款。
我做了什么:我使用 ANDROID_ID 检查安装是否唯一,但我开始知道它不是唯一的,它随设备的每个系统 upgrade/root 而变化, 所以如果有人已经 root 了他的设备并再次安装了我的应用程序,我将无法确定唯一安装。
我也检查了 IMEI 的东西,但是有些人可能会使用平板电脑等安装应用程序,在某些情况下没有 IMEI,请refer
我已经看到它可以在某些应用程序(例如 Flipkart)上正常工作。有什么想法吗?
请参考这个link:
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
有多种建议的方法:
1:
public class Installation {
private static String sID = null;
private static final String INSTALLATION = "INSTALLATION";
public synchronized static String id(Context context) {
if (sID == null) {
File installation = new File(context.getFilesDir(), INSTALLATION);
try {
if (!installation.exists())
writeInstallationFile(installation);
sID = readInstallationFile(installation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return sID;
}
private static String readInstallationFile(File installation) throws IOException {
RandomAccessFile f = new RandomAccessFile(installation, "r");
byte[] bytes = new byte[(int) f.length()];
f.readFully(bytes);
f.close();
return new String(bytes);
}
private static void writeInstallationFile(File installation) throws IOException {
FileOutputStream out = new FileOutputStream(installation);
String id = UUID.randomUUID().toString();
out.write(id.getBytes());
out.close();
}
}
我说使用,
ANDROID_ID 因为它在较新的设备上工作得相当可靠
我一直在网上苦苦寻找同样问题的答案。看来获得真正独特的东西是非常困难的。
1) Android_ID 返回 NULL 或随机狗屎'与主要制造商'
2) telephonyManager.getDeviceId() 对于没有 SIM 卡功能的设备返回 null。
您最好的办法是为可用的设备获取 IMEI 编号 (.getDeviceId()),为不可用的设备获取 ANDROID_ID。您至少可以通过只为没有 SIM 卡功能的设备推出资金来最大限度地减少损失。相信我,这是一个非常小的数字。
参考资料:这个 link 应该有所帮助。
注意:太大了 post 作为评论。
我正在与一些联盟营销公司合作,我需要通过他们推广我的 android 应用程序,但为此我需要检查我的应用程序的安装是否是独一无二的。我需要为每次安装提供一些金额,为了正确地做到这一点,我需要确定安装是否是唯一的,如果是唯一的则只放款,否则不放款。
我做了什么:我使用 ANDROID_ID 检查安装是否唯一,但我开始知道它不是唯一的,它随设备的每个系统 upgrade/root 而变化, 所以如果有人已经 root 了他的设备并再次安装了我的应用程序,我将无法确定唯一安装。
我也检查了 IMEI 的东西,但是有些人可能会使用平板电脑等安装应用程序,在某些情况下没有 IMEI,请refer
我已经看到它可以在某些应用程序(例如 Flipkart)上正常工作。有什么想法吗?
请参考这个link:
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
有多种建议的方法:
1:
public class Installation {
private static String sID = null;
private static final String INSTALLATION = "INSTALLATION";
public synchronized static String id(Context context) {
if (sID == null) {
File installation = new File(context.getFilesDir(), INSTALLATION);
try {
if (!installation.exists())
writeInstallationFile(installation);
sID = readInstallationFile(installation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return sID;
}
private static String readInstallationFile(File installation) throws IOException {
RandomAccessFile f = new RandomAccessFile(installation, "r");
byte[] bytes = new byte[(int) f.length()];
f.readFully(bytes);
f.close();
return new String(bytes);
}
private static void writeInstallationFile(File installation) throws IOException {
FileOutputStream out = new FileOutputStream(installation);
String id = UUID.randomUUID().toString();
out.write(id.getBytes());
out.close();
}
}
我说使用,
ANDROID_ID 因为它在较新的设备上工作得相当可靠
我一直在网上苦苦寻找同样问题的答案。看来获得真正独特的东西是非常困难的。
1) Android_ID 返回 NULL 或随机狗屎'与主要制造商' 2) telephonyManager.getDeviceId() 对于没有 SIM 卡功能的设备返回 null。
您最好的办法是为可用的设备获取 IMEI 编号 (.getDeviceId()),为不可用的设备获取 ANDROID_ID。您至少可以通过只为没有 SIM 卡功能的设备推出资金来最大限度地减少损失。相信我,这是一个非常小的数字。
参考资料:这个 link 应该有所帮助。
注意:太大了 post 作为评论。