Android Question getownedproducts on resume

tufanv

Expert
Licensed User
Longtime User
Hello

I have a little problem

I am checking ownedproducts with every app launch. I also want to check it on every resume.

For activity_resume , if i put
manager.getowned products i get : IAB helper not setup

if i put
manager.initialize
and then
manager.getownedproducts it is ok on resume but on first launch activity create gives error that another sync in progress

So how can i successfuly check ownedproducts on resume without any errors ?

ty
 

DonManfred

Expert
Licensed User
Longtime User
I guess you then need to

First we will intialize the "manager" and this will automaticly call the sub "manager_BillingSupported" and check if billing is supported.

reinit the manager first to get the billingsupported event to get raised?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Hello

I have a little problem

I am checking ownedproducts with every app launch. I also want to check it on every resume.

For activity_resume , if i put
manager.getowned products i get : IAB helper not setup

if i put
manager.initialize
and then
manager.getownedproducts it is ok on resume but on first launch activity create gives error that another sync in progress

So how can i successfuly check ownedproducts on resume without any errors ?

ty

you can simply use the If Firstime = true boolean

if firstime then intialize the manager and DONT run on resume and if Firsttime = false then in activity create it wont be intialized but in activity resume it will.

Activity resume will run after activity create. if the app was exit via Home Button activity create will not execute at all if you return to the app (only if android killed your process that was in the background it will run activity create at start)

but why do you want to check on every app start and resume??
i dont see the use for that
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I guess you then need to



reinit the manager first to get the billingsupported event to get raised?
If i init on resume , on first launch it inits 2 times. When first run , the app go to resume too i think and initailizes 2 times and that triggers an error.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
you can simply use the If Firstime = true boolean

if firstime then intialize the manager and DONT run on resume and if Firsttime = false then in activity create it wont be intialized but in activity resume it will.

Activity resume will run after activity create. if the app was exit via Home Button activity create will not execute at all if you return to the app (only if android killed your process that was in the background it will run activity create at start)

but why do you want to check on every app start and resume??
i dont see the use for that

I have a weekly subscription so maybe user can end the subscription but continue to see the content if not check on resume. But maybe i will not implement it on resume. You are right
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I have a weekly subscription so maybe user can end the subscription but continue to see the content if not check on resume. But maybe i will not implement it on resume. You are right

why not store a file on purchase with the date: datetime.now + (604800*1000) [=1week)

then on resume AND also on start you load the stored long to a variable called "lastpurchase"
and just check if datetime.now > lastpurchase

if TRUE ask for a new purchase and disable purchased items.

like this you even dont need to check purchased items on start. you will do it after 1 week. and if you ask what are the benefits? its very simple
this method will also work if the phone is not connected to the internet.

if your user is offline he can still use the full version because the manager could not get purchased items BUT with the method mentioned above he will not be able
to use it since you check the period that past from the last purchase. ;)
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
date can be easily changed as you know thats why i need to check it via servers =) The app is an online app so they need to be connected to internet so no problem for them.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
date can be easily changed as you know thats why i need to check it via servers =) The app is an online app so they need to be connected to internet so no problem for them.

If it is connected then you can get the time from a internet site so changing it on the phone wont do much.

But i would still prefer using an offline solution.

I would store the last purchase date as a variable and also on every start store the datetime.now as laststart variable

Now on every start and resume check if datetime.now > 1week

If true disable full version if false make another check

If datetime.now > laststart

If false user changed his clock in his phone now you can again disable full version

You may have 1 problem witb this method. If user will travel to another country and change his clock or if wintertime changed.

So i guess the check online time would be simpler and more accurate.
 
Upvote 0
Top