Android Tutorial Android InApp Purchase Tutorial + Source Code

D

Deleted member 103

Guest
Hi ilan,

thank you for this tutorial.

A question: how do I do if my app a month or a year to enable the full version?
Should I use the "Managed Product" or "subscription"?
 

ilan

Expert
Licensed User
Longtime User
A question: how do I do if my app a month or a year to enable the full version?
Should I use the "Managed Product" or "subscription"?

use "subscription".

after user buy the "subscription" product you can create a file with the purchased date and check on start if 1 month (or year) is over
and then inform the user he need to purchase that product again for another year...
 
D

Deleted member 103

Guest
Hi ilan,

where has the buyer the price before buying? Do I have the price integrate into my app? If yes, how do I do when the price changed? Do I need to change my app?
 

ilan

Expert
Licensed User
Longtime User
Hi ilan,

where has the buyer the price before buying? Do I have the price integrate into my app? If yes, how do I do when the price changed? Do I need to change my app?

no you set the price in your dev console.



you can change the price whenever you want. the user will get the updated price every time he tries to purchase the product.
 
D

Deleted member 103

Guest
no you set the price in your dev console.

View attachment 41733

you can change the price whenever you want. the user will get the updated price every time he tries to purchase the product.
I know that.
See this picture on, the buyer should know before buying what the one or the other costs, right? Or it will not work as think?
 

ilan

Expert
Licensed User
Longtime User
i dont think the lib can retrieve product details like: price, description,..

but you can do it with mysql db.
when you change the price in your dev console you also change the price in your online db and when user want to purchase you show him the price
from your mysql db.
 

ilan

Expert
Licensed User
Longtime User
btw: you should write "der einzige Unterschied..." and not "die einzige..." "der" bezieht sich auf Unterschied

EDIT: ...besteht daran "dass"... (doppel S)

EDIT: Funk(t)ionalitaten.. (t - is missing)
 
Last edited:
D

Deleted member 103

Guest
btw: you should write "der einzige Unterschied..." and not "die einzige..." "der" bezieht sich auf Unterschied

EDIT: ...besteht daran "dass"... (doppel S)

EDIT: Funk(t)ionalitaten.. (t - is missing)

Thanks for the correction.


but you can do it with mysql db.
when you change the price in your dev console you also change the price in your online db and when user want to purchase you show him the price
from your mysql db.
I think that is a bit complicated.
The question is: should I ever show the price?
 

ilan

Expert
Licensed User
Longtime User
I think that is a bit complicated.

no it is not. you can also upload a txt file to your server and in that file write the price.
then just download with http job and read the text in that txt file (without any db)

The question is: should I ever show the price?

i dont show the price. its up to you if you want to show it. anyway he will see it after he choose between month/year product. (before he purchase the product)
 
D

Deleted member 103

Guest
i dont show the price. its up to you if you want to show it. anyway he will see it after he choose between month/year product. (before he purchase the product)
Thank you, I wished to read.
 

sorex

Expert
Licensed User
Longtime User
Ilan,

Why is the init of the manager only done when firstTime=true ?

I have some problems with it when exiting the app.


When I trap the back key and let it exit with false the app closes, at restart it doesn't refresh the purchased info. (firsttime=false)

When I trap the back key and let it exit with application finish the app closes, at restart it doesn't refresh the purchased info. (firsttime=false)

When I trap the back key and let it exit with exitapplication the app closes, at restart the refresh works right. (firsttime=true)
 

ilan

Expert
Licensed User
Longtime User
Why is the init of the manager only done when firstTime=true ?

this is how @Erel did it in his tutorial, so you should ask him why. (https://b4x.com/android/forum/threads/android-in-app-billing-v3-tutorial.29997/)

When I trap the back key and let it exit with application finish the app closes, at restart it doesn't refresh the purchased info. (firsttime=false)

this is the reason i create the file because the "getownedproduct" is been called only if firsttime = true.
 

sorex

Expert
Licensed User
Longtime User
yeah, nice workaround for that problem.

pulling the init out of the if/then solves it too.

I never really understood that firsttime stuff. apps seem to resume but everything starts from scratch.
if I put it in the if/then nothing gets created. Will read that lifecycle stuff again
 

ilan

Expert
Licensed User
Longtime User
I never really understood that firsttime stuff

let say you create a map in Process_Globals.
then you fill that map with lots of informations. now if you exit your app and return (someone called you and you exit the app or you pressed the homebutton)

if you intialize the map only if firsttime = true it will still hold all informations in it but if you intialize it on activity_start also if firstime = false it will clear everything
as soon you return to your app.

this is 1 example but there are many.
 

sorex

Expert
Licensed User
Longtime User
I get the home button stuff. but not when you press back to exit it.

it's like it always starts from the beginning again with 2 cases giving firsttime false and one true (using the real exitapplication command)
 

ilan

Expert
Licensed User
Longtime User
I get the home button stuff. but not when you press back to exit it.

it's like it always starts from the beginning again with 2 cases giving firsttime false and one true

sorry i have not understood what you wrote in your last post

exitaaplication will kill your app. you should not use that way to exit your app. better use Activity.Finish

firsttime false means that your activity was still running in the background so less data to load when you return to it.

on every start activity_create will be called (even if firsttime = false) then activity_resume will be called.

so if you for exanple load a layout in activity create it will load it on every app start so you should never try to load
your layout file in "firsttimer = true" condition because you will get a blank screen when you return to your app and firsttime was false
 

ilan

Expert
Licensed User
Longtime User
anyway i think it is maybe better to start a new thread about this question.
it could help others too but it will be hard to find something about it in a different topic.

try this: https://www.b4x.com/android/forum/threads/android-process-and-activities-life-cycle.6487/

i remember erel has created a quiz about that topic and there it is very good explained but i cant find it

the search function in this forum is not good, i almost never find threads that i remember i have read before
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…