本文整理汇总了Java中com.android.vending.billing.IInAppBillingService.consumePurchase方法的典型用法代码示例。如果您正苦于以下问题:Java IInAppBillingService.consumePurchase方法的具体用法?Java IInAppBillingService.consumePurchase怎么用?Java IInAppBillingService.consumePurchase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.vending.billing.IInAppBillingService
的用法示例。
在下文中一共展示了IInAppBillingService.consumePurchase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: consumeAllPurchases
import com.android.vending.billing.IInAppBillingService; //导入方法依赖的package包/类
public static void consumeAllPurchases(Activity activity, SupportAppDevelopmentDialogFragment dialog, IInAppBillingService mService) {
try {
Bundle ownedItems = mService.getPurchases(3, activity.getPackageName(), IabHelper.ITEM_TYPE_INAPP, null);
int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
for (String purchaseData : purchaseDataList) {
JSONObject jo = new JSONObject(purchaseData);
mService.consumePurchase(3, activity.getPackageName(), jo.getString("purchaseToken"));
}
}
} catch (Exception e) {
ActivityTracker.sendEvent(activity, ActivityTracker.CAT_BE, "message_err_billing_check_error", e.getMessage(), 0L);
Log.e(TAG, "InApp billing - exception " + e.getMessage());
}
}
示例2: consumeDisposablePurchases
import com.android.vending.billing.IInAppBillingService; //导入方法依赖的package包/类
public static void consumeDisposablePurchases(Activity activity, IInAppBillingService mService) {
try {
Bundle ownedItems = mService.getPurchases(3, activity.getPackageName(), IabHelper.ITEM_TYPE_INAPP, null);
int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
for (String purchaseData : purchaseDataList) {
JSONObject jo = new JSONObject(purchaseData);
if (INAPP_CODE_DONATION_3.equals(jo.getString("productId")))
mService.consumePurchase(3, activity.getPackageName(), jo.getString("purchaseToken"));
}
}
} catch (Exception e) {
ActivityTracker.sendEvent(activity, ActivityTracker.CAT_BE, "message_err_billing_check_error", e.getMessage(), 0L);
Log.e(TAG, "InApp billing - exception " + e.getMessage());
}
}
示例3: consumePurchase
import com.android.vending.billing.IInAppBillingService; //导入方法依赖的package包/类
/**
* Wraps {@link IInAppBillingService#consumePurchase(int, String, String)}
*
* @param token Token of a purchase to consume.
*
* @return Result of the operation. Can be null.
*/
@Nullable
Response consumePurchase(@NonNull final String token) {
OPFLog.logMethod(token);
final IInAppBillingService service = getService();
if (service == null) {
return null;
}
try {
final int code = service.consumePurchase(API, packageName, token);
final Response response = Response.fromCode(code);
OPFLog.d("Response: %s", response);
return response;
} catch (RemoteException exception) {
OPFLog.e("consumePurchase request failed.", exception);
}
return null;
}
示例4: start
import com.android.vending.billing.IInAppBillingService; //导入方法依赖的package包/类
@Override
void start(@Nonnull IInAppBillingService service, int apiVersion, @Nonnull String packageName) throws RemoteException, RequestException {
final int response = service.consumePurchase(apiVersion, packageName, token);
if (!handleError(response)) {
Billing.waitGooglePlay();
onSuccess(new Object());
}
}
示例5: consumePurchase
import com.android.vending.billing.IInAppBillingService; //导入方法依赖的package包/类
public static void consumePurchase( final String purchaseData, IInAppBillingService service, String packageName )
{
try
{
// Consume the purchase for dev reset purposes
JSONObject jo = new JSONObject( purchaseData );
String token = jo.getString( "purchaseToken" );
int consumeResponse = service.consumePurchase( 3, packageName, token );
Log.d( TAG, "Purchase consumed! Response code: " + consumeResponse );
}
catch( JSONException | RemoteException e )
{
e.printStackTrace();
}
}