How to prevent Android from downloading the game outside of google

I am developing an Android application. There are currently many stores that illegally distribute free Android apps. Is there any piece of code I could write to prevent my Android app from downloading from any other store that is not a game on Google? For example, when a user tries to open an application, showing a message like β€œDo you need to buy this application on Google Play” and then close the application?

+5
source share
1 answer

Check packageInstallerName

The easiest way to check if your application is downloaded from Google Play is to check if packageInstallerName , as in the example below:

 String installer = getPackageManager().getInstallerPackageName( "com.example.myapp"); if (installer == null) { // app was illegally downloaded from unknown source. } else { // app was probably installed legally. Hooray! } 

but as we read here: fooobar.com/questions/1236078 / ...

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

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

2) Checking the packagename installer for piracy reasons is equivalent to using Base64 for password encryption - this is just bad practice.

3) Users who legally purchased the application can download the APK or restore it from another backup application that does not install the packagename installer to fix and receive a license verification error. This will most likely lead to poor reviews.

4) As you already mentioned, pirates can simply install the packagename installer when installing the APK.

So, there are only two good ways to prevent the Android app from loading outside the Google Play Store:

Adding a license to your application;

It basically guarantees that the application was purchased by the user using the device:

enter image description here

Android Link:

In-app billing

Make your app free and add in-app purchases.

In-app Billing is a Google Play service that allows you to sell digital content from your applications. You can use the service to sell a wide range of content, including downloadable content such as media files or photos, virtual content such as game or potion levels, premium services and features, and much more. You can use In-app Billing to sell products like:

  • Standard products in the application (one-time payment) or

  • Subscriptions (recurring, automatic payments)

When you use the in-app billing service to sell an item, whether it’s an in-app product or a subscription, Google Play processes all the statement details, so your application never needs to directly process any financial transactions. Google Play uses the same backend service used to purchase apps, so your users have a consistent and familiar buying process.

Any application that you publish through Google Play can implement Billing in the application.

Android Link:

Hope this helps

+5
source

Source: https://habr.com/ru/post/1236077/


All Articles