本文整理匯總了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();
}
}