question

Christopher J. Robinson avatar image
Christopher J. Robinson asked

initiatePurchaseRequest causes my Activity to get destroyed

Here's my problem. I have an activity (landscape orientation) from which I try to initiate a purchase by calling PurchasingManager.initiatePurchaseRequest(). As soon as this is called the onConfigurationChanged(Configuration newConfig) method which I have overridden in my activity is called. I assume this is happening because the in-app purchasing dialog is trying to change the orientation or something. That's fine, but for some reason the onDestroy() method in my activity get called next even though the onConfigurationChanged() handler should have prevented onDestroy from being called. This causes me serious grief due to how my application is designed. How can I prevent the initiatePurchaseRequest() call from destroying my activity?
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Christopher J. Robinson avatar image
Christopher J. Robinson answered
Ok now I'm confused. I was doing my testing initially on an HTC One. Whenever I call the initiatePurchaseRequest() method my Activity would be destroyed. Tonight I tried running it on Kindle Fire HD and to my surprise my Activity isn't getting destroyed and everything works fine. I don't understand what's different between the Fire and the HTC One. I thought I might have the "Don't keep activities" developer setting checked on my phone. That would explain the behavior but I don't. Anyone have any ideas?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Christopher, Is that happening while you are testing your app in Sandbox? Or it's in Live app?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Christopher J. Robinson avatar image
Christopher J. Robinson answered
I'm seeing it when using the SDK Tester app. I haven't tried it live.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Christopher, Thanks for the reply. Can you please post the error stack trace? Did you ever test it in another non Amazon device? Have you tried to run the sample apps provided with SDK in your HTC? Does it work? If yes, can you please make a sample app what can demonstrate the issue?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Christopher J. Robinson avatar image
Christopher J. Robinson answered
I figured out my problem. I needed to add the "screenSize" value to the "android:configChanges" attribute inside my Activity within the manifest. I already had the "orientation" value specified, but I was missing "screenSize".
According to the google Activity documentation, if your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations. With this change the activity is no longer destroyed when the in-app purchase dialog appears.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.