开发者

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

开发者 https://www.devze.com 2023-01-19 13:33 出处:网络
Can you please tell me how can I keep the MediaRecorder开发者_如何学Go keeps recording after an orientation change? I try looking into source code ofpackages/apps/SoundRecorder/src/com/android/soundre

Can you please tell me how can I keep the MediaRecorder开发者_如何学Go 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消