2012-12-26 96 views
0

我拍攝3張照相機後停止響應(崩潰)。如果我嘗試重新啓動應用程序相機狀態==鎖定並且默認相機也被鎖定。 示例代碼:3張照片後崩潰相機

private Runnable SimpleShot=new Runnable() 
{ 
    @Override 
    public void run() 
    { 
     int i=0; 
     while (i<7) 
     { 
      simpleShot(); 
      try 
      { 
       Thread.sleep(1500); 
      } catch (InterruptedException e) 
      { 
       e.printStackTrace(); 
      } 
      i++; 
     } 

    } 
}; 

private void simpleShot() 
{ 
    //System.gc(); 
    camera.takePicture(shutterCallback,rawCallback, this); 
} 

如果我不使用線程相機做第3張後沒有迴應過。請幫忙。 在最後一個方法onPictureTaken中,我調用camera.startPreview();

logcat的http://pastebin.com/qDcthyNe

@Override 
public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) 
{ 
    if(Utils.isSDAval() && Utils.PrepareAppFolder()) 
    { 
     String path = Utils.APP_FOLDER+"/"+"APP"+"_"+Utils.getDate()+ CameraPrefsActivity.EXT_PIC; 
     try 
     { 
      FileOutputStream os = new FileOutputStream(path); 
      os.write(paramArrayOfByte); 
      os.close(); 

     } catch (Exception e) 
     { 
      Utils.ShowInfo(this,getString(R.string.app_error_io)); 
      e.printStackTrace(); 
     } 

     Utils.ShowInfo(this,getString(R.string.app_shot_ok)); 
     SharedPreferences main_pref = PreferenceManager.getDefaultSharedPreferences(this); 
     String string_format = main_pref.getString("pref_preview_time","0"); 

     int timer_val = -1; 
     if(string_format.contains("0")) 
     { 
      timer_val = -1; 
     } 

     if(string_format.contains("1")) 
     { 
      timer_val = 1; 
     } 

     if(string_format.contains("3")) 
     { 
      timer_val = 3; 
     } 

     if(string_format.contains("5")) 
     { 
      timer_val = 5; 
     } 

     if(string_format.contains("10")) 
     { 
      timer_val = 10; 
     } 

     if(timer_val > 0) 
     { 
      Intent intent = new Intent(this,CameraPreview.class); 
      CameraPreview.setupActivity(path,timer_val); 
      startActivity(intent); 
     } 

    } 
    else 
    { 
     Utils.ShowInfo(this,getString(R.string.app_error_sd)); 
    } 

    paramCamera.startPreview(); 
} 
+0

plz發佈您的logcat在這裏... – MAC

+0

堆棧跟蹤在哪裏?什麼是相機?什麼是'takePicture'?等等... – m0skit0

+0

http://pastebin.com/qDcthyNe LogCat –

回答

0

This傢伙有同樣的問題,顯然它的模擬器,嘗試爲他工作的真實設備上運行它。

相關問題