handling changing device orientation during recording and drawing canvas
I have Activity with recording audio (by MediaRecorder class) in thread and in another thread I have drawing on canvas refreshing every 0,1 second (this drawing have a lot of in common with this: http://www.anddev.org/the_pizza_timer_-_threading-drawing_on_canvas-t126.html). I want my application to still working when user changes the device orientation. So I have in my AndroidManifest file in my Activity:
android:configChanges="orientation|keyboardHidden"
And in activity I have overrided this method (isRecording is boolean value):
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (isRecording && newConfig.orientation == 2)
setContentView(R.layout.main_record_land);
}
When I change the device orientation without this if above and setContentView everything works fine, as I want to works. But I want in Landscape mode to set antoher vie开发者_开发问答w. Only to change the my controls positions, but there are still the same controls, with the same ides. And when I use setContentView like in code above (after orientation change) my drawing canvas is reset and stopped. How can I make my drawing canvas (refreshing in thread) still works?
精彩评论