android - How to detect In-App Purchase's Status on Activity Result Method -
i testing in-app purchase using static references.
using static reference android.test.purchased
can't figure out how response of test purchase in onactivityresult(...)
method.
here onactivityresult(....)
method's body:
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { // todo auto-generated method stub super.onactivityresult(requestcode, resultcode, data); log.d("in-app", "data = "+data.tostring()); log.d("in-app", "request code = "+requestcode); log.d("in-app", "result code = "+resultcode); }
my logcat says:
08-16 10:48:10.114: d/in-app(3889): data = intent { (has extras) } 08-16 10:48:10.114: d/in-app(3889): request code = 666 08-16 10:48:10.114: d/in-app(3889): result code = -1
screen shots of test purchase:
1.
2.
the question that, extras should extract data object
in onactivityresult(....)
method, detect status of current test purchase (canceled, purchased, accepted, etc) , information product (json respnse
)?
highly appreciated, thanks.
i have updated onactivityresult(...)
method
int responsecode = data.getintextra("response_code", 0); string purchasedata = data.getstringextra("inapp_purchase_data"); string datasignature = data.getstringextra("inapp_data_signature"); if (resultcode == result_ok) { //purchased status = purchased try { //product details json jsonobject jo = new jsonobject(purchasedata); //purchased product id string sku = jo.getstring("productid"); } catch (jsonexception e) { e.printstacktrace(); } } else { //purchased status = not purchased }
this way have got purchase's status , purchased product's details json
.
Comments
Post a Comment