Handle orientation change in FM app
A configuration change (such as a change in screen orientation,
language, input devices, etc) causes current activity to be
destroyed, going through the activity lifecycle process of
onPause(), onStop(), and onDestroy() as appropriate. If the
activity had been in the foreground or visible to the user,
once onDestroy() is called in that instance then a new instance
of the activity will be created.
Change will ensure that activity doesn't get restarted on
orientation configuration changes.
Change-Id: Ie991c90528834dd6106a586dccdd20a11a701fab
diff --git a/fmapp2/AndroidManifest.xml b/fmapp2/AndroidManifest.xml
index bc383fe..482a85e 100644
--- a/fmapp2/AndroidManifest.xml
+++ b/fmapp2/AndroidManifest.xml
@@ -57,6 +57,7 @@
android:clearTaskOnLaunch="true"
android:allowTaskReparenting="true"
android:launchMode="singleTask"
+ android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="false" >
<intent-filter>
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 6561aec..fb5ca1a 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -41,6 +41,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
+import android.content.res.Configuration;
import android.media.AudioSystem;
import android.media.AudioManager;
import android.media.MediaRecorder;
@@ -429,6 +430,12 @@
}
@Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ Log.d(LOGTAG, "onConfigurationChanged");
+ super.onConfigurationChanged(newConfig);
+ }
+
+ @Override
public void onRestart() {
Log.d(LOGTAG, "FMRadio: onRestart");
try {