问题描述
我在与 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 (将#修改为@)