Reputation: 105
i currently have a class that'll play audio Files, however if i tilt my screen to horizontal or portrait, it just restarts. How can i make my app continue from where it left off after i tilt my screen? Note that i do not want my app to be fixed in the portrait/horizontal position.
Public void Play(){
AudioRenderer mr = new AudioRenderer();
mp = mr.AudioRenderer(filePath);
}
private class AudioRenderer extends Activity {
private MediaPlayer AudioRenderer(String filePath) {
File location = new File(filePath);
Uri path = Uri.fromFile(location);
mp= MediaPlayer.create(this, path);
}
return mp}
Thanks a lot!!
Upvotes: 2
Views: 1579
Reputation: 5020
you should add the following line in each of your activity Element in android menifest file
android:configChanges="orientation|keyboard|keyboardHidden"
Upvotes: 1
Reputation: 6376
You can accomplish this by setting an attribute on your activity in your AndroidManifest.xml file. This tells your activity to not kill the activity and call onCreate again on orientation or keyboard changes
<activity android:name="YourActivity" android:configChanges="orientation|keyboardHidden"/>
Upvotes: 5