I am running an application in which i am running an audio when it is clicked on image, while audio is being played and i changed the mode from landscape to portrait or from portrait to landscape and click on image, it plays another audio clip i.e. 2 audios are being played now. But this issue does not occur by clicking the images in the same mode. Is there any way to stop the previous activity when mode is changed?

Recommended Answers

All 3 Replies

When you switch orientation the activity is recreated and onCreate is recalled so you have to use the bundle to save your current state and restore after an orientation change. You can see this in action if you have just an app with a TextView and you enter text and change orientation. If you bundle your state for onCreate you can curb this. This is probably also why you have a NullPointer after the orientation changes. It is annoying as all hell but something we have to live with.

can you please share the code that saves the state? I am in a great trouble because of this :(

You can see it here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.