我刚遇到了这个奇怪的问题。我的应用程序崩溃了
Fatal Exception: java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Camera.java)
尽管如此,我尝试设置的效果列在parameters.getSupportedColorEffects()
。
有没有人遇到过类似的问题?我想这是特定于设备的错误,因为我只能在三星Galaxy S4上重现它(我只从这个设备获得了Crashlytics报告)。效果为blackboard
和whiteboard
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();
}