0

Android の請求を機能させようとしています。うまくいったような気がします。自分のデバイスでテストすると正しい動作が得られますが、ライブ アプリで請求を解除すると、正しく動作しません。

これが私がすることです:

    @Override
    public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
            int quantity, long purchaseTime, String developerPayload) 
    {
        if (purchaseState == PurchaseState.PURCHASED) 
        {                
            // Product ids are "3" and "4"

            if ( itemId != null && itemId.trim().equals("android.test.purchased") )
            { 
               // DURING TESTING THIS WORKS AND GETS INTO THIS IF CASE  
       Intent myIntent = new Intent(ExtraHelpActivity.this, PsychologyActivity.class);
       ExtraHelpActivity.this.startActivity(myIntent);                
            }
            else
            if ( itemId != null && itemId.trim().equals("3") )
            {
               // WHEN THE USER BUYS PRODUCT WITH ID "3" FOR SOME REASON CODE DOES NOT GET HERE.

               Intent myIntent = new Intent(ExtraHelpActivity.this, PsychologyActivity.class);
       ExtraHelpActivity.this.startActivity(myIntent);
            }
            else
            if ( itemId != null && itemId.trim().equals("4") )
            {   
                Intent myIntent = new Intent(ExtraHelpActivity.this, NumberOfBusinessesActivity.class);
        ExtraHelpActivity.this.startActivity(myIntent); 
            }
        }
        else 
        if (purchaseState == PurchaseState.CANCELED) 
        {  
            // purchase canceled
        } 
        else 
        if (purchaseState == PurchaseState.REFUNDED) 
        {
            // user ask for a refund
        }
    }

そして私はこれを次のように呼びます:

Button psychology = (Button)findViewById(R.id.psychology); 

psychology.setOnClickListener(new Button.OnClickListener() 
{  
    public void onClick(View v) 
    { 
    if(mBillingService.checkBillingSupported(Consts.ITEM_TYPE_INAPP))
        { 
                                //OK
        } 
    else 
    {
             // Send them to the screen of the article.
         Intent myIntent = new Intent(ExtraHelpActivity.this, PsychologyActivity.class);
         ExtraHelpActivity.this.startActivity(myIntent);    
    }


    try
    {   
        if (mBillingService.requestPurchase(issueProductIdPsych, 
                              Consts.ITEM_TYPE_INAPP ,  null)) 
        {                         

            } 
    }
    catch ( Exception e )
    {   }
    }
});

itemId が「3」であり、機能するテスト値ではない場合に onStateChange メソッドが機能しない理由を誰かが知っていますか?

ありがとう!

4

0 に答える 0