简体   繁体   中英

my android in-app purchase not working with error product could not be purchased

i am developing android in-app application with static In-app Product ID: android. test. purchased that is working good and i also get Toast message: Thank you.You item will be appear shortly. but in actual Product ID:com.android.example not working properly.and i don't know toast message class now i am what to do.

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mainview=(ImageView)findViewById(R.id.comcontractsol);

    mBillingObserver = new AbstractBillingObserver(this) {

        @Override
        public void onBillingChecked(boolean supported) 
        {
            Dungeon.this.onBillingChecked(supported);
        }

        @Override
        public void onPurchaseStateChanged(String itemId, PurchaseState state) 
        {

            if(itemId.equals("android.test.purchased"))
            {       
                mainview.setBackgroundResource(R.drawable.unlock);
                Dungeon.this.onPurchaseStateChanged(itemId, state);
                startActivity(new Intent(getApplicationContext(), secondActivity.class));
            }
        }
        @Override
        public void onRequestPurchaseResponse(String itemId, ResponseCode response) 
        {
            Dungeon.this.onRequestPurchaseResponse(itemId, response);
        }
    }

you should care about your product_id and item_id . if product_id cant match then error will be accure.

1.Create .apk file and upload it in android market but do not publish it only publish your product id.

2.now change your static id with real id and run it.

If you want "com.android.example" as product id then you have to follow these steps:

  1. Create .apk file and upload it in android market but do not publish it .

  2. Find In-App purchase(items) link and create a product and publish it . The product name must be same as "com.android.example" . So I suggest you to use a meaningful product Id.

See this similar question

In order to test your application, you have to create test account see this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM