0
我有一个代码,从互联网上的应用程式内计费和我想使用该代码在我的应用程序,但我得到一个错误,当我点击我的应用程序的的buy button
重定向我到另一个layout
的代码,我得到另一个Button
,然后点击我的应用内结算开始。如何启动一个应用程式内结算活动
我希望当我点击我的buy button
时,应用程序开票应该开始。没有任何其他button
点击。
这是在应用内计费开始的代码。
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSP = PreferenceManager.getDefaultSharedPreferences(this);
Log.i("BillingService", "Starting");
setContentView(R.layout.contact_market);
mContext = this;
mPurchaseButton = (Button) findViewById(R.id.main_purchase_yes);
mPurchaseButton.setOnClickListener(this);
mPreview = (TextView) findViewById(R.id.chakkde);
startService(new Intent(mContext, BillingService.class));
BillingHelper.setCompletedHandler(mTransactionHandler);
}
public Handler mTransactionHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
Log.i(TAG, "Transaction complete");
Log.i(TAG, "Transaction status: "
+ BillingHelper.latestPurchase.purchaseState);
Log.i(TAG, "Item purchased is: "
+ BillingHelper.latestPurchase.productId);
if (BillingHelper.latestPurchase.isPurchased()) {
showItem();
}
};
};
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.main_purchase_yes:
if (BillingHelper.isBillingSupported()) {
BillingHelper.requestPurchase(mContext,
"android.test.purchased");
} else {
Log.i(TAG, "Can't purchase on this device");
mPurchaseButton.setEnabled(false);
}
break;
default:
Log.i(TAG, "default. ID: " + v.getId());
break;
}
}
private void showItem() {
mPreview.setVisibility(View.VISIBLE);
SharedPreferences.Editor prefEditor = mSP.edit();
prefEditor.putBoolean(DroidSugarPreference.KEY_ENABLE,
true);
prefEditor.commit();
startActivity(new Intent(InAppMain.this, Setup.class));
InAppMain.this.finish();
}
@Override
protected void onPause() {
Log.i(TAG, "onPause())");
super.onPause();
}
@Override
protected void onDestroy() {
BillingHelper.stopService();
super.onDestroy();
}
}
这一点,如果从我所说的以上级
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.gtask_button:
startActivity(new Intent(getActivity(), InAppMain.class));
default:
break;
}
,但现在我想从案例R.id.gtask_button:我应该开始,我从开始应用内结算活动R.id.main_purchase_yes。
事先日Thnx ...
我从这里HTTP得到了应用内结算代码://博客。 blundell-apps.com/simple-inapp-billing-payment/#comment-529 – Jpm 2012-08-09 10:25:25
先生谈到amIDead()返回从那里而已。并显示在日志 – Jpm 2012-08-09 10:35:39
“无法在此设备上购买”一切都正常运行,如上图所示,当我从Inappmain.class开始。 – Jpm 2012-08-09 10:37:09