Dou Software
Dou Software

Reputation: 19

How do I know if the app has been downloaded from Google Play once

I have an Android mobile application that works with the membership system. There are links to other mobile applications and games in my application. With Packet Manager, I can check whether the application in the link is installed on the phone. My goal is to check whether users have downloaded the game and mobile applications on the device by clicking the links in my application. If they downloaded the application in the given link once (first time), they will earn 10 points. If they download the same application many times, they will be considered as one time. I wanted to ask you that If users download an app more than once, how do I count it just one time?

 private boolean appInstalledOrNot(String uri) {
     PackageManager pm = getPackageManager();
     boolean app_installed = false;
     try {
         pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
         app_installed = true;
     } catch (PackageManager.NameNotFoundException e) {
         app_installed = false;
     }
     return app_installed;
 }

 public void go(View view) {
         boolean installed = appInstalledOrNot("com.dousoftware.pubgtyolar");
         //loaded
         if (installed) {
             Toast.makeText(this, "Loaded", Toast.LENGTH_SHORT).show();
         } else {
             Intent viewIntent = new Intent("android.intent.action.VIEW",
                 Uri.parse("https://play.google.com/store/apps/details? 
                     id = com.dousoftware.pubgtyolar "));
                     startActivity(viewIntent); Toast.makeText(this, "Not Loaded", Toast.LENGTH_SHORT).show();
                 }

             }

Upvotes: 1

Views: 746

Answers (2)

dommilosz
dommilosz

Reputation: 127

If user click link

  1. Check that user don't have this application

  2. Redirect to store page.

  3. Set in the config file that this link has been clicked

  4. If user install application and Script triggers (eg on app opening) add points. Add points only if Link has been marked as clicked.

  5. Mark the link in config file as used to not give more points from the same app.

You can store this data on your server to avoid eg uninstalling abuse

Simply save somewhere information that link has been used

Upvotes: 0

Lev M.
Lev M.

Reputation: 6269

The short answer is: you can't.

There is no way to know, locally, on an Android device, how many times the user installed or uninstalled an app.

The long answer is that there may be some workarounds, each with its own advantages and disadvantages.

While your app is installed, you could register to ACTION_PACKAGE_ADDED and ACTION_PACKAGE_REMOVED broadcasts.

These will be called every time the user installs or removes any app. They have EXTRA_PACKAGE_NAME that contains the app package name.

This however, presents some problems:

  1. This will only work while your app is installed and the user has opened your app at least once.

  2. You will receive this broadcast for any app, and will have to filter the results yourself.

  3. If the user clears data or uninstalls and reinstalls your app, you will lose count.

Another way, and how most apps do it, is by using a referral framework. One example is Iron Source which will let you set up rewards for installing and using different apps.

If the other app is also yours, you can simply use Firebase.

Note however, that referral tracking compromises user privacy, so you have to be careful to comply with any local laws such as GDPR.

Also, using these frameworks may cost money.

Upvotes: 1

Related Questions