Mediaplayer state saving at orientation change or state change - android-activity

I am new to android.I want to know how to save the state of the mediaplayer at orientation change or state change.
Thanks in advance

Related

iPhone 4s 6.1.2 version UIViewcontroller gets refreshed on taking a image using camera

I've recorded an audio and then captured an image using my application's camera.
After that when I return to my view controller the recording data is reset or its refreshed. No recorded file exists.
Why does this issue happen only on iPhone 4s? Why does the view gets reset after using camera?
Because when you dismiss the ImagePickerController then your ViewWillAppear method will be called & All functionaly has been reset same as When view loads first time.
You need to save the functionality or check the condition on viewWillAppear method.
YOu can also set the fiunctionality on Cancelbutton press Or ImagePicker is dismiiss delegate method of ImagePicker to save the functionlity.

Application Restarted on Orientation change,How To save State?

I am building an app that changes every time the user clicks on a button the text view changes and moves to another part of the activity...When the orientation is changed the view is destroyed and recreated.
How can i save it to be the same as it was before, and save the last button the user clicked, to put them back where they were.
You can subscribe the Sensor Events that will let you know when the orientation has been changed. When this event is fired fire all your data into a DataState object and send back to the Activity. When the activity is started up again it will check to see if the DataState object is not null and you can restore the state from that!
I am aware this answer is a bit jumbled but it is possible to do this. I'm just not sure on the specifics.
http://developer.android.com/reference/android/hardware/SensorManager.html

Reset iPhone App - applicationDidEnterBackground

I'm looking to reset my application completely when it becomes inactive.
I dont want any states retained, is there an easy way to do this?
Would this be done in the Background Method? or any other of the State Methods within the application delegate?
I would suggest disabling iOS 4 backgrounding by adding the key UIApplicationExitsOnSuspend to your info.plist

How to respond to interface orientation changes?

I know the app delegate can say "yo man, I want thais new landscape orientation!" or "no thanks, don't want landscape!" and then the device won't do it.
How to implement this?
The active view controller's shouldAutorotateToInterfaceOrientation: method determines whether the interface will rotate.
For launch, there is a key in your Info.plist file that needs to be set if you want to be able to launch in orientations other than portrait.
I prefer to get the orientation notification by registering UIDeviceDidChangeOrientationNotification. The delegate of UIViewController about orientation always confuses me. I prefer to control the animation effect by myself.

iPhone SDK: Observe current time of AVAudioPlayer

is there a best practice for getting an event on every second of playback of an AVAudioPlayer instance? I need to change a view automatically depending on the current playback time.
Thank You!
You could start one or more instances of NSTimer when playback starts, and change the view when the timer(s) fire.