androidandroid-activityandroid-mediarecorderonconfigurationchanged

Android MediaRecorder. Continue recording after screen rotation


I have simple app that records audio using MediaRecorder class. When screen orientation changes audio recording stops. How can I continue recording after screen rotation? Is android:configChanges="orientation" the only way?


Solution

  • You can try and move the MediaRecorder reference and recording logic to a Fragment with no UI that will be retained across the orientation change. To achieve this, you should mark the fragment instance using setRetainInstance(true).