//EMAIL SENDING CODE FROM ASSET FOLDER
email = editTextEmail.getText().toString();
subject = editTextSubject.getText().toString();
message = editTextMessage.getText().toString();
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("file/html");
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://com.example.deepa.xmlparsing/file:///android_assets/Combination-1.html"));
startActivity(Intent.createChooser(emailIntent, "Send email using"));
Run Code Online (Sandbox Code Playgroud)
最后,我从资产文件夹(Combination-1.html)获取文件.
它越来越好了
找不到运行时错误文件异常.
有没有其他方式发送文件附件?
我试图检索存储在assets目录中的文件的引用到名为的文件myfile.pdf.我试过这样做:
File file = new File("android_assest/myfile.pdf);
Log.d("myTag", "" + file.isFile());
Run Code Online (Sandbox Code Playgroud)
不知何故,false当目录中myfile.pdf存在do 时,我得到了assets.我验证使用它getAssets().list("")和Log.d()返回的数组中的每个元素.
更多其中,我试图获取PDF文件的参考,然后使用已安装在设备上的任何PDF查看器,以便查看PDF.
我想自从上一个问题(检索对文件的引用)返回false后,下一个剪切代码失败:
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("file:///android_asset/myfile.pdf"));
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
任何人都有一个线索,为什么我无法检索文件的引用?为什么我不能使用已安装的PDF查看器来显示PDF(在检索PDF文件的引用后)?
谢谢.