I am developing billing-in-app module. But still having some issues.
1) I've implemented License Verification Library(LVL). All done like sample application and tested successfully. But I got error message that : "CHECK_LICENSE permission is not allowed for free application." when upload the app to the market. I thought that I need to implement LVL because it is related security issue of billing-in-app . But it seems that LVL is only for Paid Application. My application is free and included billing in app module. When it is available for free app ?
2) I've implemented billing-in-app module like the following when payment processed successfully (will call purchasedInApp() method):
private class MyAppPurchaseObserver extends PurchaseObserver {
public MyAppPurchaseObserver(Handler handler) {
super(MyAppPurchaseObserver.this, handler);
}
@Override
public void onBillingSupported(boolean supported) {
//Doing something
}
@Override
public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
int quantity, long purcha开发者_JAVA百科seTime, String developerPayload) {
if(purchaseState == PurchaseState.PURCHASED) {
purchasedInApp();
}
}
@Override
public void onRequestPurchaseResponse(RequestPurchase request,
ResponseCode responseCode) {
if (responseCode == ResponseCode.RESULT_OK) {
//OK
} else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
//Canceled
} else if(responseCode == ResponseCode.RESULT_BILLING_UNAVAILABLE ||
responseCode == ResponseCode.RESULT_ITEM_UNAVAILABLE ||
responseCode == ResponseCode.RESULT_SERVICE_UNAVAILABLE ||
responseCode == ResponseCode.RESULT_DEVELOPER_ERROR) {
//Error
} else {
//Fail
}
}
@Override
public void onRestoreTransactionsResponse(RestoreTransactions request,
ResponseCode responseCode) {
if (responseCode == ResponseCode.RESULT_OK) {
//OK
} else {
//Error
}
}
}
Above implemented methods are called in main thread ? Or is it separated thread ?
Thanks in advance.
As far as I know, LVL and in-app billing are independent of one another. The only thing they share is that they use your public key for verification. For in-app billing, your app needs to be built with the com.android.vending.BILLING
permission.
The billing requests are sent asynchronously to another app on the phone (Android Market or MyApps, depending on the phone). I don't believe that the request issuing methods block, so it's okay to run them on the UI thread or on a background thread. I don't know if the response call-backs are on the UI thread, but I doubt it (since they aren't for LVL).
精彩评论