2011-03-09 139 views
0

我使用的代碼幾乎與谷歌的Camera app代碼相同,但得到的結果很奇怪。在我的應用程序和Google的相機應用程序中,預覽會卡住或被奇怪的線條覆蓋。預覽通常是我在手機自己的相機應用程序中看到的最後一件事。奇怪的三星Galaxy S相機預覽

三星的型號是I9003。在三星剛剛停產的I9000上,相同的代碼運行良好。該代碼也適用於HTC Wildfire。

對此的任何解決方案?


只是注意到,在我的應用程序內拍攝照片後,相機預覽變得正常。 Google相機應用程序中也出現同樣的情況。

+1

你可以把截圖?儘管我通常從開發者那裏聽說三星設備是開發的不錯選擇。不知道這個事實。 – 2011-03-09 07:41:13

+0

是的,這樣做。我的代碼在早期的Galaxy S上運行得很完美,不幸的是它被盜了,所以我想我會購買同樣的產品以避免任何衝擊。我猜想運氣不好。 – Abhinav 2011-03-09 07:49:14

+0

解決了這個問題。無法通過Eclipse獲得預覽。將很快發佈解決方案。 – Abhinav 2011-03-09 09:55:54

回答

0

無法提前發佈答案。不知道這是否是正確的做法,但現在應用程序在150臺左右的設備上正常運行,我猜這是有效的。

所以其的onCreate功能Android相機應用有以下代碼:

  /* 
     * To reduce startup time, we start the preview in another thread. 
     * We make sure the preview is started at the end of onCreate. 
     */ 
     Thread startPreviewThread = new Thread(new Runnable() { 
      public void run() { 
       try { 
        mStartPreviewFail = false; 
        startPreview(); 
       } catch (CameraHardwareException e) { 
        // In eng build, we throw the exception so that test tool 
        // can detect it and report it 
        if ("eng".equals(Build.TYPE)) { 
         throw new RuntimeException(e); 
        } 
        mStartPreviewFail = true; 
       } 
      } 
     }); 
     startPreviewThread.start(); 

出於某種原因,這並沒有對GT-I9003工作。我注意到,拍攝照片後,預覽會正常顯示,因此硬件沒有任何問題。我試圖回顧照片拍攝後發生的情況,然後將其與照相機首次初始化的代碼進行比較。我從onCreate註釋掉了這段代碼。從相機應用的的onResume是這樣的:

if (mSurfaceHolder != null) { 
    // If first time initialization is not finished, put it in the 
    // message queue. 
    if (!mFirstTimeInitialized) { 
     mHandler.sendEmptyMessage(FIRST_TIME_INIT); 
    } else { 
     initializeSecondTime(); 
    } 
} 

我把它改爲:

 if (!mFirstTimeInitialized) { 
      initializeFirstTime(); 
     } else { 
      initializeSecondTime(); 
     } 

有一些其他的變化太大,就會把它在GitHub上作爲一個單獨的應用程序很快。

+0

剛剛注意到這也發生在Google Goggles應用中。 :P – Abhinav 2011-05-20 15:44:27

相關問題