2

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?

Tret
  • 75
  • 5
  • maybe the problem is not in the media recording, how are you handling the screen rotation and the recreation of activity or fragment? – xanexpt Nov 17 '15 at 14:46
  • I use onRetainCustomNonConfigurationInstance() to save data from old activity. And getLastCustomNonConfigurationInstance() to get it. – Tret Nov 18 '15 at 06:47

1 Answers1

2

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).

Danail Alexiev
  • 7,624
  • 3
  • 20
  • 28