我正在为我的应用程序中的产品实施Inapp计费,因为我提到了地牢示例并从中实施!但现在我不打算在我的应用程序中显示checkout对话框,我甚至没有在logcat中出现任何错误。该应用程序在一个没有连接消息的对话框中显示结果为ERROR
我正在使用log来跟踪问题。我用来显示结帐对话框的代码是 在我的主要课程::::::::::
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent j = getIntent();
int position = j.getExtras().getInt("BId");
System.err.println("Bid="+position);
Log.i("J","gf");
mHandler = new Handler();
mBooksPurchaseObserver = new BooksPurchaseObserver(mHandler);
mBillingService = new BillingService();
mBillingService.setContext(this);
mItemName = getString(CATALOG[position].nameId);
mSku = CATALOG[position].sku;
System.err.println("mSku_______="+mSku);
System.err.println("mItemName____="+mItemName);
System.err.println("Consts.DEBUG=="+Consts.DEBUG);
ResponseHandler.register(mBooksPurchaseObserver);
if (mBillingService.checkBillingSupported()) {
Log.i("ds","bsc_checkconnection");
}
if (Consts.DEBUG!=true) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
Log.i("x","x");
}
mPurchaseDatabase = new PurchaseDatabase(this);
if(!mBillingService.requestPurchase(mItemName, mSku)){
Log.e("this is exp","request purchase______________");
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
}
setupWidgets();
Log.i("ga","Request purchaseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
// Check if billing is supported.
Log.i("ga","Request purchaseeeeeeeeeee");
}
在结算服务类::::
class RequestPurchase extends BillingRequest {
public final String mProductId;
public final String mDeveloperPayload;
public RequestPurchase(String itemId) {
this(itemId, null);
Log.i("ga","Request purchase");
}
public RequestPurchase(String itemId, String developerPayload) {
// This object is never created as a side effect of starting this
// service so we pass -1 as the startId to indicate that we should
// not stop this service after executing this request.
super(-1);
System.err.println("itemId="+itemId);
Log.i("fads","request only");
mProductId = itemId;
mDeveloperPayload = developerPayload;
}
@Override
protected long run() throws RemoteException {
Log.i("gaaaaaaaaa","Request purchase");
Bundle request = makeRequestBundle("REQUEST_PURCHASE");
request.putString(Consts.BILLING_REQUEST_ITEM_ID, mProductId);
// Note that the developer payload is optional.
if (mDeveloperPayload != null) {
request.putString(Consts.BILLING_REQUEST_DEVELOPER_PAYLOAD, mDeveloperPayload);
}
System.err.println("mService===="+mService);
Bundle response = mService.sendBillingRequest(request);
System.err.println("response__"+response);
System.err.println("response__!!!!!!!!!!!!"+Consts.BILLING_RESPONSE_PURCHASE_INTENT);
PendingIntent pendingIntent
= response.getParcelable(Consts.BILLING_RESPONSE_PURCHASE_INTENT);
System.err.println("Pending Intent==="+pendingIntent);
Log.i("12","12");
if (pendingIntent == null) {
Log.e(TAG, "Error with requestPurchase");
return Consts.BILLING_RESPONSE_INVALID_REQUEST_ID;
}
Log.i("2","2");
Intent intent = new Intent();
Log.i("222222","11111");
System.err.println("Intent is equals to__"+intent);
System.err.println("pendingIntent is equals to__"+pendingIntent);
// System.err.printf("fsd",ResponseHandler.buyPageIntentResponse(pendingIntent, intent));
ResponseHandler.buyPageIntentResponse(pendingIntent, intent);
Log.i("f","fdas");
return response.getLong(Consts.BILLING_RESPONSE_REQUEST_ID,
Consts.BILLING_RESPONSE_INVALID_REQUEST_ID);
}
@Override
protected void responseCodeReceived(ResponseCode responseCode) {
Log.i("response code","response code");
ResponseHandler.responseCodeReceived(BillingService.this, this, responseCode);
}
}
我的CheckbillingSupporting类
class CheckBillingSupported extends BillingRequest {
public CheckBillingSupported() {
// This object is never created as a side effect of starting this
// service so we pass -1 as the startId to indicate that we should
// not stop this service after executing this request.
super(-1);
}
@Override
protected long run() throws RemoteException {
Bundle request = makeRequestBundle("CHECK_BILLING_SUPPORTED");
Bundle response = mService.sendBillingRequest(request);
System.err.println("response code____"+Consts.BILLING_RESPONSE_RESPONSE_CODE);
int responseCode = response.containsKey(Consts.BILLING_RESPONSE_RESPONSE_CODE)
? response.getInt(Consts.BILLING_RESPONSE_RESPONSE_CODE)
: ResponseCode.RESULT_BILLING_UNAVAILABLE.ordinal();
if (Consts.DEBUG) {
Log.i(TAG, "CheckBillingSupported response code: " +
ResponseCode.valueOf(responseCode));
}
boolean billingSupported = (responseCode == ResponseCode.RESULT_OK.ordinal());
ResponseHandler.checkBillingSupportedResponse(billingSupported);
return Consts.BILLING_RESPONSE_INVALID_REQUEST_ID;
}
}
有人告诉我,我错了吗?