当前位置: 首页>>代码示例>>Java>>正文


Java IInAppBillingService.consumePurchase方法代码示例

本文整理汇总了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());
  }
}
 
开发者ID:Daskiworks,项目名称:ghwatch,代码行数:17,代码来源:DonationService.java

示例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());
  }
}
 
开发者ID:Daskiworks,项目名称:ghwatch,代码行数:18,代码来源:DonationService.java

示例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;
}
 
开发者ID:onepf,项目名称:OPFIab,代码行数:25,代码来源:GoogleBillingHelper.java

示例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());
	}
}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:9,代码来源:ConsumePurchaseRequest.java

示例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();
	}
}
 
开发者ID:Wavesonics,项目名称:RingMyPhoneAndroid,代码行数:16,代码来源:Debug.java


注:本文中的com.android.vending.billing.IInAppBillingService.consumePurchase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。