B4A Library App downloaded from Google Play or Amazon Lib

hi,

this is my 3rd lib. with this lib you can check if your app was downloaded from the google play store or the amazon store or from NO store and do what ever you want (like close the app or turn on self destruction :D)

now you can easily catch people that have bought your app, backed-up the apk, uninstalled it and get a refund. so no more working for free :)

note that it is not a 100% protection but at least it will be a little bit harder for people to use your paid apps for free.

the lib is very simple:

Step 1, we intialize the lib (store_check) in activity_create like this:

B4X:
Sub Activity_Create(FirstTime As Boolean)

'Intialize
    Dim check As store_check
    check.Initialize
'......

then we just check if app was downloaded from the store like this:

B4X:
    If check.notfromGoogle Then Log("this app was NOT downloaded from the google play store")  Else Log("check ok or unknow")

you may also do it (if you like) only if "Firsttime = True".

I have not tested it on an amazon app, only on google play app and it worked see attached pictures

Pic1 = installed from my PC
Pic2 = installed from Google Play

If you find any bugs please let me know, and if you like to donate me a small (or big) amount i would be very happy. :)

PS: Please make some tests before you update all your apps, i dont know if there is a minimum SDK or anything else so you use this lib on your own risk :cool:

EDIT:

Version 1.01
Version 1.02 (Bug fixed)

Version 1.03 (after @Erel has explained how to compile a code module it is now working correctly)

New Method: Check any peckagename (app) if it is installed from the Store

B4X:
    If check.notfromGoogle2("com.android.gallery") Then Log("this app was NOT downloaded from the google play store")  Else Log("check ok or unknow")

COMPLETE CODE MODULE: https://www.b4x.com/android/forum/t...e-play-or-amazon-lib.65377/page-2#post-414562

I also want to thank to @JordiCP and to @DonManfred

1.jpg
 

Attachments

  • Example.zip
    1.6 KB · Views: 440
  • Lib v1.03.zip
    4.1 KB · Views: 432
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
so if you get that your app was installed from the store OR that package name does not exist then you will get returned a FALSE boolean and you dont want to make any action, correct?
.

I do want to take action. If package is not available then I want to alert user to install it and exit the app until it is installed.

4000 items in an array list is really not much. but to have 4000 installed apps is far to much. so i guess no one will have more then 200 apps installed but anyway you can make your tests and see that a list can handle very easily 4000 items and very quick.

I was logging each one of those package names using For/Next statement with debugger on and painfully took 8 logs per seconds. Something strange was happening in Debug and Release mode. I need to look into this further.
 

Scantech

Well-Known Member
Licensed User
Longtime User
4000 items in an array list is really not much. but to have 4000 installed apps is far to much. so i guess no one will have more then 200 apps installed but anyway you can make your tests and see that a list can handle very easily 4000 items and very quick.

After further investigation, the library is causing an issue with reading the list. It is logging at 1 per second with the following codes
B4X:
             For x = 0 To check.GetInstalledPeckageList.Size  - 1    'way to long
            Log(check.GetInstalledPeckageList.Get(x))
        Next

The solution is create a new list and transfer the library list.
B4X:
             Dim l As List
        l.Initialize
        l.AddAll(check.GetInstalledPeckageList)
      
        For x = 0 To l.Size  - 1
            Log(l.Get(x))
        Next
 
Last edited:

ilan

Expert
Licensed User
Longtime User
After further investigation, the library is causing an issue with reading the list. It is logging at 1 per second with the following codes
B4X:
             For x = 0 To check.GetInstalledPeckageList.Size  - 1    'way to long
            Log(check.GetInstalledPeckageList.Get(x))
        Next

The solution is create a new list and transfer the library list.
B4X:
             Dim l As List
        l.Initialize
        l.AddAll(check.GetInstalledPeckageList)
     
        For x = 0 To l.Size  - 1
            Log(l.Get(x))
        Next

i don't get such behavior, working fine when i use GetInstalledPeckageList.
 
D

Deleted member 103

Guest
Hi @ilan,

I noticed that when an app is cloned with app app-cloner, your library is no longer working. :(

Probably now must also still be examined whether this app is installed.
 

ilan

Expert
Licensed User
Longtime User
Hi @ilan,

I noticed that when an app is cloned with app app-cloner, your library is no longer working. :(

Probably now must also still be examined whether this app is installed.

i really dont understand why google let such apps be available in the store. :mad:
so why create apps for sale? you can buy an app, clone it, and delete the original. then you get a refund and keep using the cloned one.

really awesome! :mad:

after you remove the original do you still get the the app was purchased from the store?

btw i came to a conclusion long time ago that the best way and secure way to create app is using Free Apps with inAppPurchasing and not create a lite version and a full version separately. so now i try to do that and no more full apps!
 
D

Deleted member 103

Guest
after you remove the original do you still get the the app was purchased from the store?
I have not tried, but as now is, is shit enough. :mad:
 
Top