Android in app purchase quick guide.

Android in app purchase quick guide.

Few days before i have posted in google+ about android in app purchase. The discussion is totally interesting. Here is the link for google+ post

Here is text of post i have extracted.

I would like to integrate in-app purchases in my app.

But i have few questions.

  1. If app user successfully purchase item how can i activate feature? Does another apk will be downloaded from playstore? Does google play developer console manages these?

  2. If i have to manage in same app which is installed Should i use some persistance mechanism like database or shared preferences after user successfully made purchase? If yes than my most important question is , if user uninstall app or clear data from settings, how that purchase will be restored? Does user have to re-purchase that feature again?


  1. After purchase you will obtain some response with product id. Then you can activate your feature – this is your responsibility.
    You can save info about the purchase and use it in the app.
    Also there is an API which allows to check if some product has been purchased. You can check this at the start-up of the app or have special option for do this. Anyway you should have this, because the store will not allow the user to buy the same product.
    This is true if product is not consumable (i.e. not like extra money in the game).
    Also take into account that there are can be following cases which can be handled if you check that the product has been purchased:
  • User redeem the product via promocode.
  • User buy the product on one device, but uses multiple devices (in this case the user think that the feature will be available on all devices).
  1. Using in-app billing API v3, your app calls getPurchases() to retrieve the features the user has purchased.

They are stored on the Google Play server so if the app is reinstalled the user will get his purchases back.

Purchases are cached locally on the device so you don’t need to manage your own database of purchased items if you don’t want to.
3. +Christophe Beyls ( thanks, but how can i activate feature ?
Before user purchase feature how can i check that user has not yet made purchase so that let app disable that feature.
4. You disable the feature by default and only enable it when it is returned in the list returned by getPurchases().
5. Play store should cache the value, but it happens several times that is not true or the caching period is really too low, so yes, you need to have some backup because for example the device has no connectivity.


File manipulation in programming using template

Recently i am working on one desktop application. The requirement is to develop ui which can generate configuration file which is used in to run one external application which is written in some other language. Config file which i have to generate is not a plain coma separated file but has complicated structure with configuration parameter. Also the application must run on Linux as well as on windows. So i decided to built with java swing. Based on my previous experience with Java swing i did easily developed user interface with java swing controls.

Now user interface is developed and i have to move on next task which is config file generation based on parameters values filled by the user. I have decided that i will use File class and generate expected file line by line with proper parameter values. In between my mentor back from his vacation and we are discussing about this task. He told me that i should not use File operation manually instead i have to use some template engine which will use source file with place-holders and i have to pass that place-holders values from the program where i am handling ui events. I have started looking for such implementation and try to implement such structure. He has also suggested some way using regular expressions.
Continue reading “File manipulation in programming using template”