Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recognize specific apk build, even if user update apk in Google Play

I need to recognize users with specific apk build. This build has some features comparing to normal apk (like some functions are PRO at start).

build for GooglePlay------>
                           ----> next version of apk
build for some Customers-->

I thought about saving some data to database, so even if I update apk I, will have pernament data no matter what version user will have.

The problem happens when the user didn't run the application but immediately updated to next version. User didn't initialize sqlite, so no data was stored.

Is there any way to keep data and reuse it even if user updated base apk to newer version?

like image 790
deadfish Avatar asked Aug 11 '17 11:08

deadfish


People also ask

Can APK files be updated?

At the moment, there's no direct way as such to get updates on Apk files installed on your device. All you can do is, uninstall the file and re-install it from authenticate and trusted sources to get its latest version.

How do I find an APK code?

May be the easy one to see the source: In Android studio 2.3, Build -> Analyze APK -> Select the apk that you want to decompile . You will see it's source code.

What is the difference between APK and app?

App bundles are publishing format, whereas APK (Android application Package) is the packaging format which eventually will be installed on device. Google uses app bundle to generate and serve optimized APKs for each user's device configuration, so they download only the code and resources they need to run your app.


2 Answers

You can't, at least not without root or any other "patch"-solutions.

There are a few solutions which doesnt work well and need some preparation.

Solution 1:

Create a second App which must be preinstalled and have a PACKAGE_ADDED receiver. Onec it receives the installation of your App it will run it at least onec.

Solution 2:

Create a BOOT_COMPLETED receiver but this means that the device need to reboot to get activated. Even with this solution it may or may not work. Since Android 3.1 google have added a security policy to require (the most devices) that the App has been started at least one time to get in activate-state (some manufacturer dont have this security policy).

Solution 3: (Only working solution)

Create a different Package for your "Customers-App". Onec the app is installed from Playstore and started, it will validate if an app with the customers-namespace is installed. If yes, then it will start to do your Customers-Sqlite-Stuff and uninstall the app after.

Example:

com.myapp.customer -> installed com.myapp.playstore -> installed -> started -> validate if com.myapp.customer is installed and activate the "customers routine" -> remove com.myapp.customer

Edit:

Using Androids Gradle Plugin 3+ allows your to create flavors which allows you to create different package names / builds easily. https://developer.android.com/studio/build/build-variants.html

like image 111
Emanuel S Avatar answered Oct 21 '22 04:10

Emanuel S


In my understanding, your app is completely offline.

If it is offline. You can only identify the user is a pro by asking them.

You can make users get pro features by entering Promo code. get the promo code from the user and provide them pro features.

If your app is Online and has web services.

Then you can simply check pro users when they open the app by calling your server and provide them Pro features.

Another idea is checking Build Number and provide the pro features.

Get the version number by calling BuildConfig.VERSION_CODE

like image 1
Bhuvanesh BS Avatar answered Oct 21 '22 05:10

Bhuvanesh BS