Android相机API:getSupportedColorEffects可以返回不支持的效果吗?

时间:2016-05-02 12:46:00

标签: java android android-camera

我刚遇到了这个奇怪的问题。我的应用程序崩溃了

Fatal Exception: java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Camera.java)

尽管如此,我尝试设置的效果列在parameters.getSupportedColorEffects()

有没有人遇到过类似的问题?我想这是特定于设备的错误,因为我只能在三星Galaxy S4上重现它(我只从这个设备获得了Crashlytics报告)。效果为blackboardwhiteboard

编辑:添加了一些代码,但这不是很必要,我在帖子中描述了整个问题。

public void setColorEffect(String colorEffect)
{
    if (mCamera != null)
    {
        Parameters params = mCamera.getParameters();
        params.setColorEffect(colorEffect);
        mCamera.setParameters(params);
    }
}

仅在popupWindow项目点击时调用此方法,该项目仅包含来自getSupportedColorEffects的值:

final List<String> colorEffects = mPreview.getSupportedColorEffects();
if (colorEffects != null)
{
    final CustomPopUpAdapter adapter = new CustomPopUpAdapter(this, colorEffects.toArray(new String[colorEffectsSize]));
    adapter.setSelectedItem(items[savedColorEffect]);
    final ListPopupWindow popupWindow = new ListPopupWindow(this);
    // ...
    popupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {
            mPreview.setColorEffect(colorEffects.get(position));
            savedColorEffect = position;
            popupWindow.dismiss();
        }
    });
    popupWindow.show();
}

0 个答案:

没有答案