1

我正在为我的应用程序中的产品实施 Inapp 计费,因为我引用了地下城示例并从中实施!但是现在我不打算在我的应用程序中显示结帐对话框,我什至没有在 logcat 中收到任何错误。应用程序在没有连接消息的对话框中将结果显示为错误

我正在使用日志跟踪问题。我用来显示结帐对话框的代码在我的主类中::::::::::

 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;
    }
}

谁能告诉我我错了吗?

4

0 回答 0