在Android中将json文件附加到电子邮件意图

在Android中将json文件附加到电子邮件意图,android,json,android-intent,Android,Json,Android Intent,在Android中,如何将JSONObject作为json文件附加到电子邮件意图 我目前的代码是: JSONObject jsonObj = new JSONObject("text"); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, "blabla"); intent.putExtra(Intent.EXTRA_S

在Android中,如何将JSONObject作为json文件附加到电子邮件意图

我目前的代码是:

JSONObject jsonObj = new JSONObject("text");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "blabla");
intent.putExtra(Intent.EXTRA_SUBJECT, "blabla");
intent.putExtra(Intent.EXTRA_TEXT, "blabla");
startActivity(Intent.createChooser(intent, "Send Email"));
试试这个:

JSONObject jsonObj = new JSONObject("text");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "blabla");
intent.putExtra(Intent.EXTRA_SUBJECT, "blabla");
intent.putExtra(Intent.EXTRA_TEXT, "blabla");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/file.json"));
startActivity(Intent.createChooser(intent, "Send Email"));

1.从json对象2创建.txt文件。首先创建json文件并保存在sdcard中,然后随附电子邮件