介绍
在设置菜单的-安全和紧急情况-打开急救信息中-用户选择姓名拍好头像后,进行横竖屏操作,头像被重新刷新了没有保存,对于横竖屏的切换保存数据,我们考虑的一般会想到Activity中如下的两个方法
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState)
public void onRestoreInstanceState(Bundle savedInstanceState, PersistableBundle persistentState)
分析
我们在onSaveInstanceState中埋log调用的方法中也一样发现getDialog().isShowing()这个不满足条件判断所以导致保存数据失败
路径:vendor/mediatek/proprietary/packages/apps/EmergencyInfo/src/com/android/emergency/preferences/EmergencyNamePreference.java
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getEmergencyNamePreference().onSaveInstanceState(outState);
}
修改
找打对应路径
路径:vendor/mediatek/proprietary/packages/apps/EmergencyInfo/src/com/android/emergency/preferences/EmergencyNamePreference.java
public void onSaveInstanceState(Bundle outState) {
//*/soda water.20230922 Save a temp user photo
if (getDialog() != null
/*/
if (getDialog() != null && getDialog().isShowing()
//*/
&& mEditUserPhotoController != null) {
// Bitmap cannot be stored into bundle because it may exceed parcel limit
// Store it in a temporary file instead
File file = mEditUserPhotoController.saveNewUserPhotoBitmap();
if (file != null) {
outState.putString(KEY_SAVED_PHOTO, file.getPath());
}
}
if (mWaitingForActivityResult) {
outState.putBoolean(KEY_AWAITING_RESULT, mWaitingForActivityResult);
}
}