Android IAB设置从未完成
我找了好几个小时想弄清楚这件事。以下是我到目前为止所做的。 (注:我正在Android Studio中开发)Android IAB设置从未完成,android,in-app-billing,android-billing,Android,In App Billing,Android Billing,我找了好几个小时想弄清楚这件事。以下是我到目前为止所做的。 (注:我正在Android Studio中开发) 生成已签名的APK并上载到我的开发者控制台 制作应用内产品并将其激活 已将计费权限添加到我的清单中 广泛梳理堆栈,试图找到类似的问题 基本上在logcat中,我看到IbaHelper启动了安装程序,但从未在任何时候完成。(侦听器从未收到回调) private static final String TAG=“首选项活动”; 私有静态最终字符串SKU_PRO=“desk.clock.PRO
private static final String TAG=“首选项活动”;
私有静态最终字符串SKU_PRO=“desk.clock.PRO.license”;
静态最终int RC_请求=10001;
艾伯曼帮助者;
私有布尔错误;
私人ArrayList proSettings;
IInapplingService mService;
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
绑定服务(新)
意图(“com.android.vending.billing.InAppBillingService.BIND”),
mServiceConn,Context.BIND_AUTO_CREATE);
proSettings=newarraylist();
ActionBar b=getActionBar();
b、 setDisplayHomeAsUpEnabled(真);
colorListener();
肌理学家();
bgColorListener();
onPresetListener();
梯度监听器();
字符串base64Key=“[my key from dev console]”;
绑定服务(新)
意图(“com.android.vending.billing.InAppBillingService.BIND”),
mServiceConn,Context.BIND_AUTO_CREATE);
mHelper=新的IABHeloper(此,base64Key);
mHelper.enableDebugLogging(true);
Log.d(标签“启动设置”);
mHelper.startSetup(新的IabHelper.OnIabSetupFinishedListener(){
已完成公共void ONIBS设置(IAB结果){
如果(!result.issucess()){
//哦,不,有个问题。
Log.d(标签,“应用内计费设置问题:+结果”);
}
Log.d(标签“设置成功”);
Log.d(标记“查询库存”);
mHelper.queryInventoryAsync(mGotInventoryListener);
Log.d(标记“查询”);
}
});
IabHelper.QueryInventoryFinishedListener管理InventoryListener
=新建IabHelper.QueryInventoryFinishedListener(){
QueryInventoryFinished上的公共无效(IabResult,
存货(库存){
if(result.isFailure()){
//在这里处理错误
失误=错误;
禁用ProAndRevertSettings();
}
否则{
//用户是否有高级升级?
mIsPremium=存货。hasPurchase(SKU_PRO);
如果(失误){
使能prosettings();
}否则{
禁用ProAndRevertSettings();
}
}
}
};
ServiceConnection MSServiceConn=新的ServiceConnection(){
@凌驾
ServiceDisconnected上的公共无效(组件名称){
mService=null;
}
@凌驾
服务连接上的公共无效(组件名称,
IBinder服务){
mService=IInAppBillingService.Stub.asInterface(服务);
}
};
//我其余的活动
我的日志里有这句话,但此后再也没有
10-06 15:46:44.485 20787-20787/com.ssa.digitaldeskclock D/D﹕ 开始应用内计费设置。通过获取IAB v3示例的所有util类的新版本,问题得到了解决。我将所有新文件添加到我的util目录中,并且运行正常。希望这可以帮助其他人。有关源代码,请参阅此链接
您是否在实际设备上进行测试?这在模拟器上不起作用。是的,我一直在我的HTC one上进行测试,它与我的开发者帐户注册到同一个帐户。
private static final String TAG = "Preference Activity";
private static final String SKU_PRO = "desk.clock.pro.license";
static final int RC_REQUEST = 10001;
IabHelper mHelper;
private boolean mIsPremium;
private ArrayList<Preference> proSettings;
IInAppBillingService mService;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
proSettings = new ArrayList<Preference>();
ActionBar b = getActionBar();
b.setDisplayHomeAsUpEnabled(true);
colorListener();
textureListener();
bgColorListener();
onPresetListener();
gradListener();
String base64Key = "[my key from dev console]";
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
mHelper = new IabHelper(this, base64Key);
mHelper.enableDebugLogging(true);
Log.d(TAG, "Starting setup");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
Log.d(TAG, "Setting up success");
Log.d(TAG, "querying inventory");
mHelper.queryInventoryAsync(mGotInventoryListener);
Log.d(TAG, "queried");
}
});
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
mIsPremium = false;
disableProAndRevertSettings();
}
else {
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PRO);
if(mIsPremium) {
enableProSettings();
}else {
disableProAndRevertSettings();
}
}
}
};
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
//rest of my activity