From d54793dcfa5b10c843083b2b43dadd3b912a5c0c Mon Sep 17 00:00:00 2001
From: Kamal Negi <kamaln@codeaurora.org>
Date: Wed, 30 Mar 2016 10:30:33 +0530
Subject: [PATCH] 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
---
 fmapp2/AndroidManifest.xml              | 1 +
 fmapp2/src/com/caf/fmradio/FMRadio.java | 7 +++++++
 2 files changed, 8 insertions(+)

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.DialogInterface.OnKeyListener;
 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;
@@ -428,6 +429,12 @@ public class FMRadio extends Activity
        return mFrequency;
    }
 
+   @Override
+   public void onConfigurationChanged(Configuration newConfig) {
+       Log.d(LOGTAG, "onConfigurationChanged");
+       super.onConfigurationChanged(newConfig);
+   }
+
    @Override
    public void onRestart() {
       Log.d(LOGTAG, "FMRadio: onRestart");
-- 
GitLab