Android 画廊在拍照后崩溃(意图)
拍照并单击“提交”按钮后,Gallery应用程序崩溃。这是怎么可能的?我该如何修复它?我的应用程序中从未明确使用该库 我使用MediaStore.ACTION\u IMAGE\u CAPTURE启动相机。 为了将图片保存到文件系统,我使用了此处提供的代码: 顺便说一句,我使用的是摩托罗拉TC55和安卓4.1(API 16) 代码片段:Android 画廊在拍照后崩溃(意图),android,android-intent,android-camera,Android,Android Intent,Android Camera,拍照并单击“提交”按钮后,Gallery应用程序崩溃。这是怎么可能的?我该如何修复它?我的应用程序中从未明确使用该库 我使用MediaStore.ACTION\u IMAGE\u CAPTURE启动相机。 为了将图片保存到文件系统,我使用了此处提供的代码: 顺便说一句,我使用的是摩托罗拉TC55和安卓4.1(API 16) 代码片段: Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
return;
}
// Continue only if the File was successfully created
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(getContext(),
"com.example.android.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {
File imgFile = new File(imagePath);
if(imgFile.exists()) {
if (HttpManager.isNetworkAvailable(getContext())) {
// Send the picture to the webserver (start AsyncTask)
} else {
// Save the call to process it later
}
}
}
}
logcat中没有可用的日志,因为我的应用程序没有崩溃。
在开始操作后,在logcat中添加的行只有以下几行:
07-29 08:57:13.081 31473-31473/com.test.test W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
[ 07-29 08:57:13.081 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 3, fd = 82, size = 462848, offset = 0
[ 07-29 08:57:13.091 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 4, fd = 88, size = 462848, offset = 0
[ 07-29 08:57:13.091 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 5, fd = 94, size = 462848, offset = 0
有时候我会这样:
07-29 09:01:19.464 12604-12604/com.test.test W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
当上一页(或类)中的输入连接尚未关闭时,就会出现此类问题。检查是否已关闭上一个类中的输入连接(通过提供connection.close())
当您离开活动并保持HTTP连接打开时,会出现此问题 当上一页(或类)中的输入连接尚未关闭时,就会出现此类问题。检查是否已关闭上一个类中的输入连接(通过提供connection.close())
当您离开活动并保持HTTP连接打开时,会出现此问题 我使用示例项目中的代码修复了它:
我认为问题在于Android 4.1与文件提供商不完全兼容。因此,在将图片保存到文件(在Gallery应用程序中)时出现故障。示例代码还没有使用它。我使用示例项目中的代码修复了它:
我认为问题在于Android 4.1与文件提供商不完全兼容。因此,在将图片保存到文件(在Gallery应用程序中)时出现故障。示例代码还没有使用它。请提供日志、加载日志和创建意图的代码片段以及onActivityResult方法。代码片段添加了您需要加载崩溃日志的内容。嗯,伙计。。没有日志数据,我们如何检查。。问题在哪里,或者问题是什么。。?你的应用程序没有崩溃,没问题。。但这并不意味着没有日志数据。重新启动studio或eclipse和emulator,再次检查提供的日志,请加载日志和创建意图和onActivityResult方法的代码片段。代码片段添加您需要加载崩溃日志。嗯,伙计。。没有日志数据,我们如何检查。。问题在哪里,或者问题是什么。。?你的应用程序没有崩溃,没问题。。但这并不意味着没有日志数据。请重新启动studio或eclipse和emulator,并检查againI closed(.disconnect())HttpURLConnection,但不幸的是,它没有解决问题。我已关闭(.disconnect())HttpURLConnection,但不幸的是,它没有解决问题