HelloWorld HelloWorld - 2 months ago 14
Android Question

Codename One wasPurchased() method : Is it supported on Android devices?

For my Codename One app, I am trying to figure out whether I can tell if an in-app-purchase (non consumable) has already been bought on Android (code shown in my other SO question).

According to this 2014 question it seems that managed purchases are not supported on Android. However when I test

on Android it returns true, and I can buy an In-App-Purchase.

So managed purchases seem to be supported on Android. However
remains false even after successful purchase although this Google Group discussion seems to say that
does work indeed.

I tried to reach the source code for that
but could not find anything usefull (maybe I did not find the right code pieces).

So I am completely at lost, since my code works on the simulator as expected but not on a real Android device (which could also be faulty). Consequently could someone tell me if
is working on Android (in that case my Android device is faulty) or if I have to implement some native Android code to do what
is expected to do ?

EDIT November 10th 2016 : Solved with suffix "_nonconsume

As written in the blog post @Shai showed in his answer by default Google play considers the product as consumable. That's why in case of non consumable product
returned false. To make Google Play treat the In-App-Product as non-consumable, you have to use the suffix "_nonconsume" in the SKU name in the developper console (eg : "myappfull_nonconsume"). Then wait a few hours after submitting your app to the alpha testing channel and when the app is available, Google play will remember the purchase and
will work as expected.

Any help appreciated,


This might be more useful: https://github.com/codenameone/CodenameOne/blob/master/Ports/Android/src/com/codename1/impl/android/CodenameOneActivity.java#L191-L209

That's the piece that actually gets called. Support for managed purchases was added a few years ago when we migrated to the new Android in-app-purchase 3 API: https://www.codenameone.com/blog/migrating-to-androids-in-app-purchase-30.html