最近在学习大神的第一行代码,发现总是提示The application may be doing too much work on its main thread.这个错误。开始没太在意,因为就安卓模拟器的运行来说,有些小例子是可以测试的。但是最近看到了返回数据在logcat中看,但是由于提示The application may be doing too much work on its main thread.这个错误,总是不能看到logcat的值

01-19 04:14:52.720 2830-2858/com.example.activitytest D/OpenGLRenderer: endAllActiveAnimators on 0x8f0e1880 (RippleDrawable) with handle 0x9bceaf90
01-19 04:16:23.037 2830-2830/com.example.activitytest I/Choreographer: Skipped 56 frames!  The application may be doing too much work on its main thread.
01-19 04:16:27.238 2830-2830/com.example.activitytest I/Choreographer: Skipped 52 frames!  The application may be doing too much work on its main thread.
01-19 04:16:33.055 2830-2830/com.example.activitytest I/Choreographer: Skipped 47 frames!  The application may be doing too much work on its main thread.
01-19 04:16:35.288 2830-2830/com.example.activitytest I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.
01-19 04:16:36.370 2830-2830/com.example.activitytest I/Choreographer: Skipped 51 frames!  The application may be doing too much work on its main thread.
01-19 07:02:23.004 2830-2830/com.example.activitytest I/Choreographer: Skipped 242 frames!  The application may be doing too much work on its main thread.
01-19 07:02:28.840 2830-2830/com.example.activitytest I/Choreographer: Skipped 125 frames!  The application may be doing too much work on its main thread.
这是logcat提示。
 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_layout);
        Button button1 = (Button) findViewById(R.id.button_1);
        button1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
               Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
                startActivityForResult(intent,1);
            }
        });
    }
这是FirstActivity中的更改 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second_layout);
       Button button2 =(Button) findViewById(R.id.button_2);
        button2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent intent = new Intent();
                intent.putExtra("data_return","Hello FirstActivity");
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }
这是SecondActivity中的更改。这个例子郭霖大神给出的打印信息是
com.example.activity D/FirstActivity:Hello FirstActivity
来论坛找了很多提示The application may be doing too much work on its main thread.这种的错误,发现都是很大规模的程序,那我这种小例子的测试怎么会提示这种呢?费解。求大腿指教一二,感激不尽。

解决方案 »

  1.   

    你看看你的Activity有没有定义跳转动画。。最好把onActivityResult 的代码也贴下
      

  2.   

    代码肯定是没有问题我觉得,因为我反复确认过。我是按照书上所说去选择了basic 或者选择empty都是会提示这个。
    现在看到一百多页了,不管运行什么例子都提示这个。醉了,请问是安装环境有问题了么,还是我在创建项目的时候出现问题了
      

  3.   

    我当时自学的时候也是这个提示,一直logcat里面弹弹弹,百度结果就是不要在主线程做太多的耗时操作,耗时的交给子线程,避免主线程阻塞。不过你也不用管这个,完全没啥影响的,先学东西再说。