求教,如果程序发生anr,还会有log产生么。
在activity启动过程中就发生anr,但是连oncreat里的log都没有请大牛指点

解决方案 »

  1.   

    anr也有log的 首先adblog 会提示你 哪里产生了anr  在data/data/trace.*文件 里面就是anr  log
      

  2.   


    anr日志一般情况下好像是在data/anr/traces.txt至于没有执行onCreate方法,你自己也可以去截取adb log查看的
      

  3.   

    ANR只能说明主线程阻塞 如果子线程打印LOG无影响
      

  4.   


    我的程序是启动一个画图程序,因为是自定义了一个view继承了SurfaceView,然后creat中自定义view中的creat里的log也没有打印,activity中creat的log也没有打印,会发生这样的情况么。自定义view里会跑一个线程
      

  5.   

    这个activity是收到一个intent启动的,出现anr的情况时直接黑屏
     @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.paint);
            
            Calendar ca =  Calendar.getInstance();
            mGetTime = ca.getTimeInMillis();
            
            paletteView = (PaletteView)findViewById(R.id.backview);
            
            bluepenButton = (Button)findViewById(R.id.bluepen);
            eraserButton = (Button)findViewById(R.id.eraserButton);
            submitButton = (Button)findViewById(R.id.submitButton);
            saveButton = (Button)findViewById(R.id.saveButton);
            
            bluepenButton.setOnClickListener(this);
            eraserButton.setOnClickListener(this);
            submitButton.setOnClickListener(this);
            saveButton.setOnClickListener(this);
          
            
            
            Bundle bundle = getIntent().getExtras();

                 
    token = bundle.getString("token");
    readPath = bundle.getString("parameter"); 
    subject = bundle.getString("subject");
    mHttpPort = bundle.getInt("httpport");

            Intent intent = new Intent();
    intent.setAction("close.bynextQuiz");
    sendBroadcast(intent);

    loadDialog = new ProgressDialog(this);
    saveDialog = new ProgressDialog(this);
    overtimeDialog = new AlertDialog.Builder(this).create();

    overtimeDialog.setCancelable(false);
    loadDialog.setCancelable(false);
    saveDialog.setCancelable(false);

            msg = new Message();       
            
            resetActivity();
                    
           
        }
        public void resetActivity(){        
        
          if( subject == null || subject.equals("") ){
          subject = "Miscellaneous";
          }
        
          loadDialog.show();
          loadDialog.setContentView(R.layout.loadpaintdialog);
          
          bluepenButton.setSelected(true);
          eraserButton.setSelected(false);
          
          thread = new Mythread();
             thread.start(); 
             }
    这是oncreat里的内容,在最开始添加log也没有任何输出。下面是oncreat里自定义view的内容:
              public PaletteView(Context context, AttributeSet arr) {
    super(context, arr); mPaint = new Paint();
    actionList = new ArrayList<Action>();
    mSurfaceHolder = this.getHolder();
    mSurfaceHolder.addCallback(this);
    this.setFocusable(true);
    mLoop = true; finbgBitmap = ((BitmapDrawable) (getResources()
    .getDrawable(R.drawable.white))).getBitmap();
    newbit = Bitmap.createBitmap(bgBitmapWidth, bgBitmapHeight,
    Config.ARGB_4444);

    myThread = new Thread(this);
    myThread.start();
    }
      

  6.   

    自己顶一下,surfaceview的创建会造成anr么,finbgBitmap = ((BitmapDrawable) (getResources()
     .getDrawable(R.drawable.white))).getBitmap()或者创建Bitmap造成了anr
      

  7.   

    建议在可能耗时的方法前后加上时间点,找出耗时的方法,然后再进行优化处理。
    最好不要把耗时的方法放在onCreate里面