我正在尝试通过电子邮件发送带有附件的表单数据的代码,但无法上传文件。遇到此异常。
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == PICKFILE_REQUEST_CODE && resultCode == RESULT_OK) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Files.FileColumns.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
columnIndex = cursor.getColumnIndex(filePathColumn[0]);
attachmentFile = cursor.getString(columnIndex);
Log.e("Attachment Path:", attachmentFile+"");
URI = Uri.parse("file://" + attachmentFile);
cursor.close();
}
}
private void openGallery() {
Log.e("Gallery callesd","hi");
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
Intent intent = new Intent();
intent.setType("application/msword");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra("return-data", true);
startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICKFILE_REQUEST_CODE);
}
}