gpt4 book ai didi

android - 如何防止在谷歌播放外下载Android应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:54:03 26 4
gpt4 key购买 nike

我正在为安卓开发一个应用程序。现在有很多商店非法免费分发安卓付费应用程序。我可以编写任何代码 fragment 来防止我的 android 应用程序从任何其他不是 google play 的商店下载吗?例如,当用户尝试打开该应用时,显示“您需要在 google play 中购买此应用”之类的消息,然后关闭该应用?

最佳答案

检查packageInstallerName

检查您的应用是否从 Google Play 下载的最简单方法是检查 packageInstallerName 是否为空,如下例所示:

String installer = getPackageManager().getInstallerPackageName(
"com.example.myapp");

if (installer == null) {
// app was illegally downloaded from unknown source.
}
else {
// app was probably installed legally. Hooray!
}

但正如我们在这里读到的:https://stackoverflow.com/a/36299631/4730812

You should not use PackageManager#getInstallerPackageName to check if the app was installed from Google Play or for licensing purposes for the following reasons:

1) The installer packagename can change in the future. For example, the installer package name use to be"com.google.android.feedback" (see [here][2]) and now it is"com.android.vending".

2) Checking the installer packagename for piracy reasons is equivalent to using Base64 to encrypt passwords — it's simply badpractice.

3) Users who legally purchased the app can side-load the APK or restore it from another backup application which doesn't set thecorrect installer packagename and get a license check error. This willmost likely lead to bad reviews.

4) Like you mentioned, pirates can simply set the installer packagename when installing the APK.

所以只有两种好方法可以防止 Android 应用程序从 Google Play 商店外下载:

为您的应用添加许可证;

基本上确保应用程序已被用户使用设备购买:

enter image description here

安卓引用:

应用内结算

让您的应用程序免费并添加内置购买。

In-app Billing is a Google Play service that lets you sell digitalcontent from inside your applications. You can use the service to sella wide range of content, including downloadable content such as mediafiles or photos, virtual content such as game levels or potions,premium services and features, and more. You can use In-app Billing tosell products as:

  • Standard in-app products (one-time billing), or

  • Subscriptions (recurring, automated billing)

When you use the in-app billing service to sell an item, whether it'san in-app product or a subscription, Google Play handles all checkoutdetails so your application never has to directly process anyfinancial transactions. Google Play uses the same checkout backendservice as is used for application purchases, so your users experiencea consistent and familiar purchase flow.

Any application that you publish through Google Play can implementIn-app Billing.

安卓引用:

希望对你有帮助

关于android - 如何防止在谷歌播放外下载Android应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33743826/

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