我怎么能保存onRetainNonConfigurationInstance()的屏幕方向的位图? [英] how can I save a bitmap with onRetainNonConfigurationInstance() for screen orientation?
问题描述
在我的课查看电话凸轮会被打开,程序显示后,用户拍照的手机凸轮位图,但同时用户旋转屏幕,风景位图将消失,活动的OnCreate()将再次加载和然后相机会再次被打开。
In my class view phone cam will be opened and programme shows the bitmap after user take photo from phone cam but at the same time the user rotates the screen to "landscape" bitmap will disappear and activity's oncreate() will load again and then camera will be opened again.
我不知道保存位图与onRetainNonConfigurationInstance()或的onSaveInstanceState()。
I didnt know save bitmap with onRetainNonConfigurationInstance() or onSaveInstanceState().
现在的问题是这样的我怎么能保存位用户旋转手机前(来自手机CAM),这样即使手机是风景模式相同的位图将在屏幕??
The question is this how can I save the bitmap(taken from phone cam) before user rotates the phone so that even if phone is landscape mode same bitmap will be showed in the screen??
---编辑--- 添加到AndroidManifest.xml中是获得节能状态的好办法?
---EDIT--- Adding to AndroidManifest.xml is a good way to obtain saving state?
推荐答案
保存它的onSaveInstanceState:
Save it onSaveInstanceState:
@Override
public void onSaveInstanceState(Bundle toSave) {
super.onSaveInstanceState(toSave);
toSave.putParcelable("bitmap", bitmap);
}
和它找回来的onCreate:
And get it back onCreate:
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
if (savedState != null) bitmap = savedState.getParcelable("bitmap");
}
这篇关于我怎么能保存onRetainNonConfigurationInstance()的屏幕方向的位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!