2021-11-25 Android bug处理记录

报错信息:

Fatal Exception: java.lang.IllegalStateException
Fragment MonitorFragment{7e39b48} not attached to Activity

处理:
加isAdded():

    public String getStrByResId(int ResId) {
        if (isAdded() && getActivity() != null ){
            String content = getResources().getString(ResId);
            return ItStringUtil.safeToString(content);
        }else{
            return "";
        }
    }

你可能感兴趣的:(2021-11-25 Android bug处理记录)