我正在使用意图选择器调用电子邮件客户端。
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, emails);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Receipt Voucher from Vawsum");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Please find the receipt voucher attached along with this mail.");
Uri outputFileUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", new File(String.valueOf(new File(String.valueOf(pdfDir), "VawsumVoucher.pdf"))));// - akash - to send third party apps big size files
emailIntent.putExtra(Intent.EXTRA_STREAM, outputFileUri);
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.setType("application/pdf");
startActivity(Intent.createChooser(emailIntent, "Send Email"));
以下是 maifest 文件中的提供程序代码:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.trakkerz.app.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"
tools:replace="android:resource"/>
</provider>
需要帮助。
有点模糊的问题,但如果你等待意图,你应该使用startActivityForResult()
而不是startActivity()
使用onActivityResult()
完成您想要完成的工作
onCreate 从电子邮件客户端返回后被调用 与文件提供程序共享大 pdf 文件
我的猜测是,您的进程已终止,而您的应用程序不在前台。这是完全正常的。