michael
michael

Reputation: 110520

How can I keep the MediaRecorder keeps recording after an orientation change

Can you please tell me how can I keep the MediaRecorder keeps recording after an orientation change? I try looking into source code of packages/apps/SoundRecorder/src/com/android/soundrecorder/Recorder.java, I don't see it handles that cases.

Thank you.

Upvotes: 1

Views: 1529

Answers (1)

Zsombor Erdődy-Nagy
Zsombor Erdődy-Nagy

Reputation: 16914

This might be because by default the system destroys and recreates the Activity when the orientation changes. You can tell the system that your app handles changes like these by modifying the activity's tag in the manifast like this:

<activity android:name=".UIActivity"
                  android:configChanges="orientation|keyboardHidden"
                  android:label="@string/app_name"> ...
</activity>

This way you can react to these changes overriding this method:

 @Override 
    public void onConfigurationChanged(Configuration newConfig) { 
        super.onConfigurationChanged(newConfig); 
        //---code to redraw your activity here---
        //...
    }

Here, you can redraw your views to support landscape mode, or do simply nothing.

Upvotes: 2

Related Questions