当我使用Android 8.0在我的OnePlus 3中拍照时,应用程序崩溃,但在我的Genymotion Android 6.0中,它运行良好。
相机意图。
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, TAKE_IMAGE_REQUEST);
我如何设置onActivityResult()
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == TAKE_IMAGE_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
Uri tempUri = getImageUri(getApplicationContext(), photo);
String path = getRealPathFromURI(tempUri);
try {
Img img = crearImg(path);
if (user.isOnline()) {
Img.uploadImage(NoteActivity.this, img);
}
} catch (Exception e) {}
}
}
我希望有人可以帮助我。
提前致谢。