Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android camera setParameters failed 類問題分析總結

android camera setParameters failed 類問題分析總結

編輯:關於Android編程

 

LOG顯示為:
09-01 18:47:17.348 15656 15675 E AndroidRuntime: FATAL EXCEPTION: Camera Handler Thread
09-01 18:47:17.348 15656 15675 E AndroidRuntime: Process: com.android.camera, PID: 15656
09-01 18:47:17.348 15656 15675 E AndroidRuntime: java.lang.RuntimeException: setParameters failed
09-01 18:47:17.348 15656 15675 E AndroidRuntime: at android.hardware.Camera.native_setParameters(Native Method)

這種情況下都是參數設置錯誤。

主要常見錯誤在以下兩個方法的參數設置

Camera.Parameters parameters = mCamera.getParameters();

parameters.setPictureSize(1600, 1200);

parameters.setPreviewSize(w, h);

該怎樣去設置好這兩個參數設置呢?

首先我們將數據獲取處理看看這兩個方法能夠傳遞那些參數進來。

List pictureSizes = parameters.getSupportedPictureSizes();
int length = pictureSizes.size();
for (int i = 0; i < length; i++) {
Log.e("TAG","SupportedPictureSizes : " + pictureSizes.get(i).width + "x" + pictureSizes.get(i).height);
}

List previewSizes = parameters.getSupportedPreviewSizes();
length = previewSizes.size();
for (int i = 0; i < length; i++) {
Log.e("TAG","SupportedPreviewSizes : " + previewSizes.get(i).width + "x" + previewSizes.get(i).height);
}

通過日志我們可以看到

05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 640x480
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 1600x1200
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 2048x1536
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 2592x1456
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 2592x1952
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 3264x1840
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 3264x2448
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 4160x2336
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 4160x3120
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPictureSizes : 3104x3104


05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 176x144
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 240x160
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 352x288
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 320x240
05-21 17:43:17.545: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 480x320
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 640x480
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 720x544
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 960x544
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 960x720
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 720x720
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 1280x720
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 1440x1080
05-21 17:43:17.550: E/FFFFFFFFFFFFFFFFFFFFF(21262): SupportedPreviewSizes : 1920x1080
05-21 17:43:17.550: E/==============(21262): ==w=1920========h=1080 隱藏返回鍵我手機對應的分辨率

所以這兩個方法裡面的參數必須是上面可以對應上的。

05-21 17:47:43.575: E/==============(21262): ==w=1794========h=1080 顯示返回鍵的分辨率

我的問題是使用榮耀6手機返回鍵和home都是在屏幕內導致高的分辨率達不到1920*1080。而實際只有1794*1080而導致錯誤。

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved