gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 18:46:06 26 4
gpt4 key购买 nike

我发布了一个 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com