【发布时间】:2021-03-02 11:03:34
【问题描述】:
当我在 Redmi 7A 上启动相机拍照时应用程序崩溃。也无法在 UncaughtException 处理程序中捕获崩溃。
抓拍后一直停留在同屏,好像没有死机,但所有数据都被清除了。
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File out = getActivity().getExternalFilesDir(null);
filename = (System.currentTimeMillis() + ".jpg");
out = new File(out, filename);
if (Build.VERSION_CODES.N <= Build.VERSION.SDK_INT) {
picUri = FileProvider.getUriForFile(getContext(), getContext().getApplicationContext().getPackageName() + ".provider", out);
i.putExtra(MediaStore.EXTRA_OUTPUT, picUri);
} else {
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out));
}
getActivity().startActivityForResult(i, ConstantsUtils.CAMERA_REQUEST_CODE);
还在清单中使用 largeHeap 以获得足够的内存
android:largeHeap="true"
并且还在清单中添加了所需的功能
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="true" />
很抱歉,我没有找到与此错误相关的任何日志,我们将不胜感激
【问题讨论】:
-
日志应该在那里,如果你在 catch 块中添加了 try catch write printStackTrace()。
标签: android android-studio android-camera redmi-device