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?
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?
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?
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.