2

我即将将付费应用发布到安卓市场。该应用程序使用 LVL(应用程序许可)。为了验证许可证,我必须提供设备的唯一 ID。问题是某些 android 设备(由于已知问题)在调用时具有相同的“唯一”ID:

Secure.getString(getContentResolver(), Secure.ANDROID_ID);

我也可以使用 TelephonyManager 类,但该应用程序还针对平板电脑设备,因此我不能依赖它。

如果你们中的任何人使用过 LVL,请告诉我您在创建 LicenseChecker() 对象时是如何获得设备 ID 的。我只是想了解如果两个具有相同设备 ID 的用户尝试购买该应用程序会发生什么。

4

2 回答 2

1

具有相同 ID 的两台设备只会将应用程序免费提供给另一台设备,但 LVL 仍然适用于 Google ID。由于 LVL 使用 Google 的身份验证,因此您很少会看到具有相同 ID 和相同 Google ID 的人购买相同的应用程序。特别是因为他们已经拥有它!

如果这没有帮助,请尝试以下方法:

http://developer.android.com/guide/publishing/licensing.html状态:

声明一个变量来保存设备标识符并以任何需要的方式为其生成一个值。例如,LVL 中包含的示例应用程序查询系统设置的 android.Settings.Secure.ANDROID_ID,每个设备都是唯一的。

请注意,根据您使用的 API,您的应用程序可能需要请求额外的权限才能获取特定于设备的信息。例如,要查询 TelephonyManager 以获取设备 IMEI 或相关数据,应用程序还需要在其清单中请求 android.permission.READ_PHONE_STATE 权限。

在仅出于获取设备特定信息以在您的混淆器中使用的目的而请求新权限之前,请考虑这样做可能会如何影响您的应用程序或其在 Android Market 上的过滤(因为某些权限可能会导致 SDK 构建工具添加相关的 .

于 2011-07-27T20:15:07.593 回答
1

有关如何为安装您的应用程序的每个 Android 设备获取唯一标识符的详细说明,请参阅此官方 Android 开发人员博客帖子:

http://android-developers.blogspot.com/2011/03/identifying-app-installations.html

似乎最好的方法是让您在安装时自己生成一个,然后在重新启动应用程序时阅读它。

我个人认为这是可以接受的,但并不理想。Android 提供的标识符在所有情况下都不起作用,因为大多数标识符取决于手机的无线电状态(wifi 开/关、蜂窝开/关、蓝牙开/关)。其他像 Settings.Secure.ANDROID_ID 必须由制造商实现,不保证是唯一的。

以下是将数据写入安装文件的示例,该文件将与应用程序在本地保存的任何其他数据一起存储。

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();
    }
}
于 2011-08-02T03:21:11.470 回答