onSaveInstanceState保存数据,onRestoreInstanceState取数据

来源:互联网 发布:991dd最新域名地址 编辑:程序博客网 时间:2024/04/30 20:43
    /**     * 存图片的路径     */    @Override    protected void onSaveInstanceState(Bundle outState) {        if (sdImageFile != null) {            Timber.i("onSaveInstanceState -- not -- null");            outState.putString(UPLOAD_PHOTO_STATUS, sdImageFile.getAbsolutePath());        }        outState.putString(UPLOAD_PHOTO_LIST_ID, listId);        Timber.i("onSaveInstanceState----outState");        super.onSaveInstanceState(outState);    }    /**     * 取图片的路径     */    @Override    protected void onRestoreInstanceState(Bundle savedInstanceState) {        super.onRestoreInstanceState(savedInstanceState);        Timber.i("onRestoreInstanceState");        String photoStatus = savedInstanceState.getString(UPLOAD_PHOTO_STATUS);        if (sdImageFile == null && !TextUtils.isEmpty(photoStatus)) {            Timber.i("new File(photoStatus);");            sdImageFile = new File(photoStatus);        }        String photoListId = savedInstanceState.getString(UPLOAD_PHOTO_LIST_ID);        if (TextUtils.isEmpty(listId) && !TextUtils.isEmpty(photoListId)) {            Timber.i("new File(photoListId);");            listId = photoListId;        }    }

0 0