/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cocos2dx.plugin.util;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import com.android.vending.billing.IInAppBillingService;
import org.json.JSONException;
import java.util.ArrayList;
import java.util.List;
/**
* Provides convenience methods for in-app billing. You can create one instance of this
* class for your application and use it to process in-app billing operations.
* It provides synchronous (blocking) and asynchronous (non-blocking) methods for
* many common in-app billing operations, as well as automatic signature
* verification.
*
* After instantiating, you must perform setup in order to start using the object.
* To perform setup, call the {@link #startSetup} method and provide a listener;
* that listener will be notified when setup is complete, after which (and not before)
* you may call other methods.
*
* After setup is complete, you will typically want to request an inventory of owned
* items and subscriptions. See {@link #queryInventory}, {@link #queryInventoryAsync}
* and related methods.
*
* When you are done with this object, don't forget to call {@link #dispose}
* to ensure proper cleanup. This object holds a binding to the in-app billing
* service, which will leak unless you dispose of it correctly. If you created
* the object on an Activity's onCreate method, then the recommended
* place to dispose of it is the Activity's onDestroy method.
*
* A note about threading: When using this object from a background thread, you may
* call the blocking versions of methods; when using from a UI thread, call
* only the asynchronous versions and handle the results via callbacks.
* Also, notice that you can only call one asynchronous operation at a time;
* attempting to start a second asynchronous operation while the first one
* has not yet completed will result in an exception being thrown.
*
* @author Bruno Oliveira (Google)
*
*/
public class IabHelper {
// Is debug logging enabled?
boolean mDebugLog = false;
String mDebugTag = "IabHelper";
// Is setup done?
boolean mSetupDone = false;
// Has this object been disposed of? (If so, we should ignore callbacks, etc)
boolean mDisposed = false;
// Are subscriptions supported?
boolean mSubscriptionsSupported = false;
// Is an asynchronous operation in progress?
// (only one at a time can be in progress)
boolean mAsyncInProgress = false;
// (for logging/debugging)
// if mAsyncInProgress == true, what asynchronous operation is in progress?
String mAsyncOperation = "";
// Context we were passed during initialization
Context mContext;
// Connection to the service
IInAppBillingService mService;
ServiceConnection mServiceConn;
// The request code used to launch purchase flow
int mRequestCode;
// The item type of the current purchase flow
String mPurchasingItemType;
// Public key for verifying signature, in base64 encoding
String mSignatureBase64 = null;
// Billing response codes
public static final int BILLING_RESPONSE_RESULT_OK = 0;
public static final int BILLING_RESPONSE_RESULT_USER_CANCELED = 1;
public static final int BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE = 3;
public static final int BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE = 4;
public static final int BILLING_RESPONSE_RESULT_DEVELOPER_ERROR = 5;
public static final int BILLING_RESPONSE_RESULT_ERROR = 6;
public static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7;
public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;
// IAB Helper error codes
public static final int IABHELPER_ERROR_BASE = -1000;
public static final int IABHELPER_REMOTE_EXCEPTION = -1001;
public static final int IABHELPER_BAD_RESPONSE = -1002;
public static final int IABHELPER_VERIFICATION_FAILED = -1003;
public static final int IABHELPER_SEND_INTENT_FAILED = -1004;
public static final int IABHELPER_USER_CANCELLED = -1005;
public static final int IABHELPER_UNKNOWN_PURCHASE_RESPONSE = -1006;
public static final int IABHELPER_MISSING_TOKEN = -1007;
public static final int IABHELPER_UNKNOWN_ERROR = -1008;
public static final int IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE = -1009;
public static final int IABHELPER_INVALID_CONSUMPTION = -1010;
// Keys for the responses from InAppBillingService
public static final String RESPONSE_CODE = "RESPONSE_CODE";
public static final String RESPONSE_GET_SKU_DETAILS_LIST = "DETAILS_LIST";
public static final String RESPONSE_BUY_INTENT = "BUY_INTENT";
public static final String RESPONSE_INAPP_PURCHASE_DATA = "INAPP_PURCHASE_DATA";
public static final String RESPONSE_INAPP_SIGNATURE = "INAPP_DATA_SIGNATURE";
public static final String RESPONSE_INAPP_ITEM_LIST = "INAPP_PURCHASE_ITEM_LIST";
public static final String RESPONSE_INAPP_PURCHASE_DATA_LIST = "INAPP_PURCHASE_DATA_LIST";
public static final String RESPONSE_INAPP_SIGNATURE_LIST = "INAPP_DATA_SIGNATURE_LIST";
public static final String INAPP_CONTINUATION_TOKEN = "INAPP_CONTINUATION_TOKEN";
// Item types
public static final String ITEM_TYPE_INAPP = "inapp";
public static final String ITEM_TYPE_SUBS = "subs";
// some fields on the getSkuDetails response bundle
public static final String GET_SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST";
public static final String GET_SKU_DETAILS_ITEM_TYPE_LIST = "ITEM_TYPE_LIST";
/**
* Creates an instance. After creation, it will not yet be ready to use. You must perform
* setup by calling {@link #startSetup} and wait for setup to complete. This constructor does not
* block and is safe to call from a UI thread.
*
* @param ctx Your application or Activity context. Needed to bind to the in-app billing service.
* @param base64PublicKey Your application's public key, encoded in base64.
* This is used for verification of purchase signatures. You can find your app's base64-encoded
* public key in your application's page on Google Play Developer Console. Note that this
* is NOT your "developer public key".
*/
public IabHelper(Context ctx, String base64PublicKey) {
mContext = ctx.getApplicationContext();
mSignatureBase64 = base64PublicKey;
logDebug("IAB helper created.");
}
/**
* Enables or disable debug logging through LogCat.
*/
public void enableDebugLogging(boolean enable, String tag) {
checkNotDisposed();
mDebugLog = enable;
mDebugTag = tag;
}
public void enableDebugLogging(boolean enable) {
checkNotDisposed();
mDebugLog = enable;
}
/**
* Callback for setup process. This listener's {@link #onIabSetupFinished} method is called
* when the setup process is complete.
*/
public interface OnIabSetupFinishedListener {
/**
* Called to notify that setup is complete.
*
没有合适的资源?快使用搜索试试~ 我知道了~
使用c++基于Cocos2dx V3.16 开发的植物大战僵尸游戏
共2000个文件
h:911个
cpp:468个
xml:386个
需积分: 0 1 下载量 161 浏览量
2024-05-10
13:52:31
上传
评论 1
收藏 162.18MB ZIP 举报
温馨提示
使用c++基于Cocos2dx V3.16 开发的植物大战僵尸游戏
资源推荐
资源详情
资源评论
收起资源包目录
使用c++基于Cocos2dx V3.16 开发的植物大战僵尸游戏 (2000个子文件)
primitives.c 13KB
Base64TranscoderFHS.c 10KB
format.c 6KB
Portrait_png.cpp 716KB
Landscape_png.cpp 679KB
PlayDisable_png.cpp 142KB
PlayEnable_png.cpp 119KB
jsb_cocos2dx_pluginx_auto.cpp 94KB
AudioMixer.cpp 80KB
lua_cocos2dx_pluginx_auto.cpp 78KB
CCBundle3D.cpp 74KB
Shine_png.cpp 69KB
CCLabel.cpp 64KB
CCActionInterval.cpp 62KB
CCTerrain.cpp 55KB
CCNode.cpp 54KB
Java_org_cocos2dx_lib_Cocos2dxEngineDataManager.cpp 54KB
CCSprite.cpp 51KB
CCTexture2D.cpp 50KB
CCPUParticleSystem3D.cpp 44KB
CCParticleSystem.cpp 43KB
CCTransition.cpp 41KB
jsb_pluginx_manual_callback.cpp 39KB
AssetsManagerEx.cpp 38KB
lua_pluginx_manual_callback.cpp 37KB
CCPURendererTranslator.cpp 37KB
CCGLProgram.cpp 35KB
CCPURender.cpp 35KB
CCPUEmitter.cpp 34KB
SimulatorWin.cpp 34KB
CCLayer.cpp 33KB
CCSprite3D.cpp 31KB
CCDrawNode.cpp 31KB
CCObjLoader.cpp 30KB
CCPhysics3DConstraint.cpp 30KB
CCGLProgramState.cpp 30KB
CCFastTMXLayer.cpp 30KB
CCRenderer.cpp 29KB
CCPhysicsWorld.cpp 29KB
CCPUEmitterTranslator.cpp 29KB
CCParticleExamples.cpp 29KB
CCPUBillboardChain.cpp 28KB
CCRenderTexture.cpp 28KB
AudioResampler.cpp 28KB
CCRenderState.cpp 27KB
CCTextureCache.cpp 27KB
CCMenuItem.cpp 27KB
CCTMXXMLParser.cpp 26KB
CCTMXLayer.cpp 26KB
CCSpriteFrameCache.cpp 26KB
CCPhysicsShape.cpp 25KB
CCGLProgramCache.cpp 25KB
AudioDecoderSLES.cpp 25KB
CCScrollView.cpp 25KB
CCMesh.cpp 25KB
CCFontFNT.cpp 24KB
SimulatorWin.cpp 24KB
CCPhysicsBody.cpp 24KB
CCAutoPolygon.cpp 23KB
Mat4.cpp 23KB
CCActionTiledGrid.cpp 22KB
CCParticleSystemQuad.cpp 21KB
CCNavMesh.cpp 21KB
CCGrid.cpp 21KB
CCSpriteBatchNode.cpp 21KB
CCFontFreeType.cpp 20KB
ProjectConfig.cpp 20KB
CCPUMeshSurfaceEmitter.cpp 20KB
CCControlButton.cpp 20KB
CCPUScriptParser.cpp 20KB
CCTextureAtlas.cpp 20KB
CCPhysicsJoint.cpp 19KB
CCApplication-tizen.cpp 19KB
CCTextFieldTTF.cpp 19KB
FileServer.cpp 18KB
CCDevice-linux.cpp 18KB
AudioPlayerProvider.cpp 18KB
CCProgressTimer.cpp 17KB
CCAnimate3D.cpp 17KB
CCPUTechniqueTranslator.cpp 17KB
CCPUScriptTranslator.cpp 17KB
CCActionGrid3D.cpp 17KB
CCCameraBackgroundBrush.cpp 17KB
Audio.cpp 16KB
AssetsManager.cpp 16KB
CCTableView.cpp 16KB
CCFontAtlas.cpp 16KB
AudioSourceReader.cpp 16KB
CCHTTPRequest.cpp 16KB
tinysndfile.cpp 16KB
CCPUDynamicAttribute.cpp 16KB
CCPhysics3DObject.cpp 16KB
AudioEngine.cpp 16KB
CCParticleBatchNode.cpp 15KB
Manifest.cpp 15KB
CCPUMaterialTranslator.cpp 15KB
mp3reader.cpp 15KB
CCPURibbonTrail.cpp 15KB
CCMenu.cpp 15KB
CCFrameBuffer.cpp 14KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
猿来如此yyy
- 粉丝: 1702
- 资源: 165
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功