如何解决在 android 11 中共享时无法将文件附加到 gmail
我在与 gmail 共享文件时遇到此错误。 “无法附加文件”。
public void shareFile (String filename,String to_email,String cc_email,String subject_email,String body_email,String isHTML,CallbackContext callbackContext) {
File file = new File(Environment.getExternalStorageDirectory() + "/"+filename);
JSONObject result = new JSONObject();
try {
result.put("filename",filename);
} catch (Exception e) {
e.printstacktrace();
}
if(file.exists()){
System.out.println("File exists");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file) );
intent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{to_email} );
intent.putExtra(android.content.Intent.EXTRA_CC,new String[]{cc_email} );
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject_email );
if(isHTML.equals("0"))
intent.putExtra(android.content.Intent.EXTRA_TEXT,body_email );
else
intent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body_email) );
cordova.getActivity().startActivity(intent);
try {
result.put("data","File attached successfully.");
} catch (Exception e) {
e.printstacktrace();
}
callbackContext.success(result);
} else {
System.out.println("File does not exist");
try {
result.put("data","error.");
} catch (Exception e) {
e.printstacktrace();
}
callbackContext.error(result);
}
}
我收到此错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。