异步任务结束操作,对于ativity fragment SharedPreferences等涉及到context操作前的判断

if (Ativity.this == null || Ativity.this.isFinishing()) {
    return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (
Ativity.this.isDestroyed()) {
        return;
}
}

 

 

if (Fragment.this.getAtivity() == null || Fragment.this.getAtivity().isFinishing()) {
    return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {//api 16+

if (
Fragment.this.getAtivity().this.isDestroyed()) {
        return;
}
}
posted @ 2016-09-02 15:14  fc_dream  阅读(300)  评论(0编辑  收藏  举报