BILLING_RESPONSE_RESULT_ERROR android 在应用内购买 AIDL?
BILLING_RESPONSE_RESULT_ERROR android in app purchase AIDL?
我的应用有应用内商品可供购买。直到昨天消费者都可以购买产品,但从今天早上开始只有我保留BILLING_RESPONSE_RESULT_ERROR。有人可以指导我解决问题吗
下面是我的购买流程代码
Bundle activeSubs = null;
try {
activeSubs = inAppBillingService.getPurchases(3,
currentActivity.getPackageName(),
"subs",
null);
} catch (RemoteException e) {
//Log.e(TAG, "Failed to retrieve current active subscriptions: " + e.getMessage());
}
ArrayList<String> subscribedSkus = null;
if (activeSubs != null) {
subscribedSkus = activeSubs.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
}
Bundle buyIntentBundle;
if (subscribedSkus != null && !subscribedSkus.isEmpty()) {
//Log.d(TAG, "Initiating upgrade purchase");
} else {
//Log.d(TAG, "Initiating new item purchase");
}
buyIntentBundle = inAppBillingService.getBuyIntentToReplaceSkus(5,
currentActivity.getPackageName(),
subscribedSkus,
skuToPurchase,
"subs",
null);
if (buyIntentBundle != null) {
int resultCode = buyIntentBundle.getInt("RESPONSE_CODE");
if (resultCode == 0) {
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
if (pendingIntent != null) {
//Log.d(TAG, "Launching intent to initiate item purchase");
currentActivity.startIntentSenderForResult(pendingIntent.getIntentSender(),
RC_PURCHASE_PLAY_STORE_ITEM,
new Intent(),
0,
0,
0);
} else {
showToast(getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.app_cms_cancel_subscription_subscription_not_valid_message)),
Toast.LENGTH_LONG);
}
} else {
if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_user_canceled)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_service_unavailable)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE) {
addGoogleAccountToDevice();
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_item_unavailable)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_DEVELOPER_ERROR) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_developer_error)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ERROR) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_error)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_item_already_purchased)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_item_not_owned)), false, null, null);
}
}
}
不知道是什么导致了这个问题。必须更改一些代码
Bundle activeSubs = null;
try {
activeSubs = inAppBillingService.getPurchases(3,
currentActivity.getPackageName(),
"subs",
null);
} catch (RemoteException e) {
//Log.e(TAG, "Failed to retrieve current active subscriptions: " + e.getMessage());
}
ArrayList<String> subscribedSkus = null;
if (activeSubs != null) {
subscribedSkus = activeSubs.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
}
Bundle buyIntentBundle;
if (subscribedSkus != null && !subscribedSkus.isEmpty()) {
//Log.d(TAG, "Initiating upgrade purchase");
} else {
//Log.d(TAG, "Initiating new item purchase");
}
String purchasePayload = "subs" + ":" + skuToPurchase;
/*buyIntentBundle = inAppBillingService.getBuyIntentToReplaceSkus(5,
currentActivity.getPackageName(),
subscribedSkus,
skuToPurchase,
"subs",
purchasePayload);*/
buyIntentBundle = inAppBillingService.getBuyIntent(3,
currentActivity.getPackageName(),
skuToPurchase,
"subs",
purchasePayload);
我们找到了解决方案(也许)。
google 播放服务发生了一些变化..直到几天前我们才有一个可用的应用程序..
顺便说一句,在我们的例子中,我们使用了
billingService.getBuyIntentExtraParams
方法..我们添加了
extraParams.putStringArrayList("skusToReplace",actualSkus);
使用 actualSkus,表示用户拥有的 skus/subscription 列表。
对于新用户,此调用生成了错误代码 6(它在几天前有效)...因此我们添加了此检查:
if ( ! actualSkus.isEmpty() )
extraParams.putStringArrayList("skusToReplace",actualSkus)
我的应用有应用内商品可供购买。直到昨天消费者都可以购买产品,但从今天早上开始只有我保留BILLING_RESPONSE_RESULT_ERROR。有人可以指导我解决问题吗
下面是我的购买流程代码
Bundle activeSubs = null;
try {
activeSubs = inAppBillingService.getPurchases(3,
currentActivity.getPackageName(),
"subs",
null);
} catch (RemoteException e) {
//Log.e(TAG, "Failed to retrieve current active subscriptions: " + e.getMessage());
}
ArrayList<String> subscribedSkus = null;
if (activeSubs != null) {
subscribedSkus = activeSubs.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
}
Bundle buyIntentBundle;
if (subscribedSkus != null && !subscribedSkus.isEmpty()) {
//Log.d(TAG, "Initiating upgrade purchase");
} else {
//Log.d(TAG, "Initiating new item purchase");
}
buyIntentBundle = inAppBillingService.getBuyIntentToReplaceSkus(5,
currentActivity.getPackageName(),
subscribedSkus,
skuToPurchase,
"subs",
null);
if (buyIntentBundle != null) {
int resultCode = buyIntentBundle.getInt("RESPONSE_CODE");
if (resultCode == 0) {
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
if (pendingIntent != null) {
//Log.d(TAG, "Launching intent to initiate item purchase");
currentActivity.startIntentSenderForResult(pendingIntent.getIntentSender(),
RC_PURCHASE_PLAY_STORE_ITEM,
new Intent(),
0,
0,
0);
} else {
showToast(getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.app_cms_cancel_subscription_subscription_not_valid_message)),
Toast.LENGTH_LONG);
}
} else {
if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_user_canceled)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_service_unavailable)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE) {
addGoogleAccountToDevice();
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_item_unavailable)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_DEVELOPER_ERROR) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_developer_error)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ERROR) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_result_error)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_item_already_purchased)), false, null, null);
} else if (resultCode == IabHelper.BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED) {
showDialog(DialogType.SUBSCRIBE, getLanguageResourcesFile().getUIresource(currentActivity.getString(R.string.subscription_billing_response_item_not_owned)), false, null, null);
}
}
}
不知道是什么导致了这个问题。必须更改一些代码
Bundle activeSubs = null;
try {
activeSubs = inAppBillingService.getPurchases(3,
currentActivity.getPackageName(),
"subs",
null);
} catch (RemoteException e) {
//Log.e(TAG, "Failed to retrieve current active subscriptions: " + e.getMessage());
}
ArrayList<String> subscribedSkus = null;
if (activeSubs != null) {
subscribedSkus = activeSubs.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
}
Bundle buyIntentBundle;
if (subscribedSkus != null && !subscribedSkus.isEmpty()) {
//Log.d(TAG, "Initiating upgrade purchase");
} else {
//Log.d(TAG, "Initiating new item purchase");
}
String purchasePayload = "subs" + ":" + skuToPurchase;
/*buyIntentBundle = inAppBillingService.getBuyIntentToReplaceSkus(5,
currentActivity.getPackageName(),
subscribedSkus,
skuToPurchase,
"subs",
purchasePayload);*/
buyIntentBundle = inAppBillingService.getBuyIntent(3,
currentActivity.getPackageName(),
skuToPurchase,
"subs",
purchasePayload);
我们找到了解决方案(也许)。
google 播放服务发生了一些变化..直到几天前我们才有一个可用的应用程序..
顺便说一句,在我们的例子中,我们使用了
billingService.getBuyIntentExtraParams
方法..我们添加了
extraParams.putStringArrayList("skusToReplace",actualSkus);
使用 actualSkus,表示用户拥有的 skus/subscription 列表。 对于新用户,此调用生成了错误代码 6(它在几天前有效)...因此我们添加了此检查:
if ( ! actualSkus.isEmpty() )
extraParams.putStringArrayList("skusToReplace",actualSkus)