Because the business needs to take pictures, take pictures (and handle compatibility issues) in a transparent Activity
Turn on the activity and directly turn up the camera. Then I found that some models have been repeatedly taking pictures on the horizontal screen. I printed it, and it turned out that the activity was destroyed and recreated because of the horizontal and vertical screen problems.
Solution one:
You can save data
/**
* 用于保存状态
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
outState.putString("data", "数据");
super.onSaveInstanceState(outState);
}
/**
* 用于恢复状态
*/
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
String data=savedInstanceState.getString("data");
}
Method Two
Not guaranteed for all models
<activity android:name=".ui.system.PhotoActivity"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="portrait"
>