Android: got CalledFromWrongThreadException in onPostExecute() - How could it be?

后端 未结 6 716
你的背包
你的背包 2020-12-13 09:48

I have an app in production for a few weeks, using ACRA, and I had zero errors until one strange error reported today.

I\'ve got:

    android.view.Vi         


        
6条回答
  •  借酒劲吻你
    2020-12-13 10:41

    Where is

    runOnUiThread(new Runnable() {
        public void run() { /*code*/ } );
    

    in your code

    /*
                 * runs on the ui thread
                 */
                protected void onPostExecute(String result) {
    
                    Activity a = getActivity();
    
                    if (S.sHelpEnabled && a != null) {
    
                        in = new InstructionsView(a.getApplicationContext());
    
                        runOnUiThread(new Runnable() {
                           public void run() {
    
                        RelativeLayout mv = (RelativeLayout) a
                                .findViewById(R.id.main_place);
    
                        mv.addView(in.prepareView());
                       }
                    }
    
                };
    

    Try this code. I think this would fix the problem

提交回复
热议问题