一行裁剪代码导致相机崩溃,如何以标准方式裁剪

Camera crashes due to crop code one line, how to crop in standard way

我的应用程序崩溃是由于 camera.putExtra("crop", "true"); 我假设这是由于一些愚蠢的不一致的供应商相机驱动程序或其他原因......我猜是分散市场的乐趣。

如果这不起作用,我该如何裁剪?最好在屏幕上有裁剪方块来引导用户。有标准的 ~99% 证明方法吗?

Android 中没有裁剪意图!!

来自https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html

Many developers are calling startActivity() on an Intent with an action of com.android.camera.action.CROP. They are doing this to crop an image.

This is a really bad idea.

In this specific case, this Intent action is supported by the AOSP Camera app. That app does not exist on all devices. Devices lacking this app will not respond to this undocumented Intent action, and your app will crash.

进一步阅读:Explanation of Android Code Camera Intent + Croping Images

本质上,上述意图在某些设备上会崩溃。

我敢打赌,如果 commonsware 的作者看到这个 post,他会解释得更好。

看看下面提到的link。

Android intent with multiple option i.e , Pick image from gallary and capture image using front camera

如果您不打算使用裁剪库

https://github.com/jdamcd/android-crop

Im assuming this is due to some stupid inconsistent vendor camera drivers or something... joys of fragmented market i guess.

主要是因为它不是 Android SDK 的一部分。不要求任何相机应用支持随机 Intent 附加功能。

How can i crop if this doesn't work?

使用a library。或编写自己的图像裁剪引擎。