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?
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With