當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。