performing pause of activity that is not resumed after recreate method

后端 未结 3 1577
刺人心
刺人心 2021-02-20 09:26

I have a project for HoneyComb and I get an error after use recreate() method at onResum() method in my main Activity.

11-10 22:05:42.090: E/ActivityThread(1917)         


        
3条回答
  •  一生所求
    2021-02-20 10:18

    To do this, use a handler:

    Handler handler = new Handler() {
           @Override
            public void handleMessage(Message msg) {
               if(msg.what==MSG_RECREATE)
                   recreate();
            }
    };
    
    @Override
    protected void onResume() {
        if(condition) {
            Message msg = handler.obtainMessage();
            msg.what = MSG_RECREATE;
            handler.sendMessage(msg);
        }
    }
    

    This will not crash anymore.

提交回复
热议问题