android - 在 Android 中限制(限制)每个帐户(由唯一设备确定)的应用程序安装

标签 android google-play

我发布了一个 Android 应用。

问题是,如果有人购买了我的应用,他可以使用同一个帐户将它安装在多台设备上。

我可以将每个帐户的安装限制为几个(比方说 2 个)唯一设备吗?

如果用户想在另一台设备上使用相同的帐户,他必须先从另一台设备上卸载。

例如,MyBackup Pro only allows two unique devices.

如何在我的应用中实现这一点?

最佳答案

Google helps you do this .

This page helps you set it up.

更具体地说,it looks like you want to add a DeviceLimiter :

In some cases, you might want your Policy to limit the number of actual devices that are permitted to use a single license. This would prevent a user from moving a licensed application onto a number of devices and using the application on those devices under the same account ID. It would also prevent a user from "sharing" the application by providing the account information associated with the license to other individuals, who could then sign in to that account on their devices and access the license to the application.

The LVL supports per-device licensing by providing a DeviceLimiter interface, which declares a single method, allowDeviceAccess(). When a LicenseValidator is handling a response from the licensing server, it calls allowDeviceAccess(), passing a user ID string extracted from the response.

If you do not want to support device limitation, no work is required — the LicenseChecker class automatically uses a default implementation called NullDeviceLimiter. As the name suggests, NullDeviceLimiter is a "no-op" class whose allowDeviceAccess() method simply returns a LICENSED response for all users and devices.

Caution: Per-device licensing is not recommended for most applications because:

It requires that you provide a backend server to manage a users and devices mapping, and It could inadvertently result in a user being denied access to an application that they have legitimately purchased on another device.

DeviceLimiter 的源代码 can be found here.

来源几乎解释了您将如何使用 DeviceLimiter 来实现您想要的:

/* The LICENSED response from the server contains a user identifier unique to
 * the <application, user> pair. The developer can send this identifier
 * to their own server along with some device identifier (a random number
 * generated and stored once per application installation,
 * {@link android.telephony.TelephonyManager#getDeviceId getDeviceId},
 * {@link android.provider.Settings.Secure#ANDROID_ID ANDROID_ID}, etc).
 *
 * The more sources used to identify the device, the harder it will be for an
 * attacker to spoof.

关于android - 在 Android 中限制(限制)每个帐户(由唯一设备确定)的应用程序安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15064563/

相关文章:

android - 我可以在 Android 2.1 的基于 Webkit 的浏览器中使用数据 URL 吗?

android - 奇怪的 SQLiteException 并非在所有设备中

android - Google Play 服务一更新就崩溃

android - keystore 和别名 - 是否有多个别名的用途?

android - 如何设置android布局以支持所有屏幕尺寸?

android - 当您在 Eclipse 中获得堆栈中包含 SDK 类的堆栈跟踪时,如何查看 SDK 源代码?

android - 如何在 Android 中绘制多行文本并在 Canvas 上旋转

android - 我们还能从 Google Play 中删除从未发布的应用吗?

android - 从网站下载 APK 并提示用户安装

google-play - 在 Google Play Console 中创建新版本显示为灰色