Android Question Detect Previous Installation

Jim McDougal

Member
Licensed User
Is there a way to detect a previous installation of an app? I'm developing a limited play version of an app with in-app purchase to buy, but I'd like to prevent users from simply uninstalling and downloading from the Play Store again for another round of free plays.
 

Jim McDougal

Member
Licensed User
I'm describing the situation where the user never buys the in-app product to unlock the permanent version, but simply uninstalls and reinstalls the trial version to get another round of free plays. As I understand, when an app is uninstalled all the files related to the app are also removed.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
My idea is this:
- A user install your app for the 1st time.
- He/She is prompted with a screen that requires him/her to click a button to start using the app and it triggers the event to consume the in-app product.
- He/She uninstall the app.
- He/She install the app again.
- The app starts but check that the in-app product is already consumed.
- He/She cannot proceed to use the app.

Note: The in-app product doesn't require the user to purchase. It is available to him/her by default.
 
Upvote 0

Jim McDougal

Member
Licensed User
So, I could have one (free) in-app product to simply monitor previous installation and another (purchase) to actually buy and unlock the permanent version?
 
Upvote 0

sfsameer

Well-Known Member
Licensed User
Longtime User
2 Solutions came to mind :

1- A minimal webservice (either B4J or PHP), Once the client installs the app (B4A/B4J/B4i) you can send the device ID to the webservice along with the installation datetime
and every time the client opens the app, run a check up with the webservice in the background to check if the client has installed this app previously or not and if the free license has expired or not.

Cons : The client can turn off the internet to prevent the check up, so you have to force the client to connect to the internet at least once (once he/she installs the app) to do the checking (You can write an empty txt file and if the file exist then the client has made the check up and if it doesn't exist then he/she didn't connect to the webservice)

*Implement certain features that require internet connection to force the client to connect to the internet.

2- request PERMISSION_WRITE_EXTERNAL_STORAGE and write a very simple txt that contains the installation datetime, once the client install the app check for this file and see if it exists and if it does then read it's contents and check when it was last installed.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
2- request PERMISSION_WRITE_EXTERNAL_STORAGE and write a very simple txt that contains the installation datetime, once the client install the app check for this file and see if it exists and if it does then read it's contents and check when it was last installed.
That won't work because minimum target API is 31 for new apps & 30 for existing ones & WRITE_EXTERNAL_STORAGE has no effect on apps targeting API 30 & above. You can try using the MANAGE_EXTERNAL_STORAGE, but unless the app is a file manager it's unlikely you'll get it on the allowlist.

https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE

- Colin.
 
Upvote 0
Top