它工作正常,但是当我点击任何地方而不是对话框以便取消时,另一个对话显示让我选择保留为草稿或丢弃。 见下面的图片..!
如果我选择 discard =>它崩溃了..!?
我在这里https://developers.facebook.com/docs/sharing/android
应用了同样的东西但这是代码:
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// this line is for facebook and it's causing the crash
callbackManager.onActivityResult(requestCode, resultCode, data);
// the ones below are for photoPicker and camera
if (resultCode == RESULT_OK) {
if (data != null) {
Log.i("onActivityResult: ", data.toString() + "");
final File file = new File(data.getData().getPath());
if (file.exists()) {
Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
BSheetPost(myBitmap);
}
Toast.makeText(
this,
String.format("Saved to: %s, size: %s", file.getAbsolutePath(), fileSize(file)),
Toast.LENGTH_LONG)
.show();
}
} else if (requestCode == PickConfig.PICK_PHOTO_DATA) {
if (data != null) {
ArrayList<String> selectPaths = (ArrayList<String>) data
.getSerializableExtra(PickConfig.INTENT_IMG_LIST_SELECT);
Bitmap bitmap = BitmapFactory.decodeFile(selectPaths.get(0));
BSheetPost(bitmap);
}
} else if (data != null) {
Exception e = (Exception) data.getSerializableExtra(MaterialCamera.ERROR_EXTRA);
if (e != null) {
e.printStackTrace();
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
logcat的
Java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64207, result=-1, data=Intent { (has extras) }} to activity {com***Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getPath()' on a null object reference
图片