我正在以这种方式实现一种简单的方式来在我的应用中发送反馈。
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL,
new String[] { "my mail" });
email.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
email.putExtra(Intent.EXTRA_TEXT, "My feedback is");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
但是我想实施反馈,例如Gmail,添加系统日志,屏幕截图,而不显示我的电子邮件,如图片所示。
有解决这个问题的想法吗?
尝试一下,这将发送您应用的日志
val outputFile = File(
getExternalFilesDir(null),
"logcat.txt"
)
try {
Runtime.getRuntime().exec(
"logcat -f " + outputFile.absolutePath
)
} catch (e: IOException) { // TODO Auto-generated catch block
e.printStackTrace()
}
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "vnd.android.cursor.dir/email"
val to = arrayOf("[email protected]")
emailIntent.putExtra(Intent.EXTRA_EMAIL, to)
emailIntent.putExtra(
Intent.EXTRA_STREAM,
FileProvider.getUriForFile(this, authorityName, File(outputFile.absolutePath))
)
emailIntent.putExtra(
Intent.EXTRA_SUBJECT,
"Subject"
)
startActivity(Intent.createChooser(emailIntent, "Send email..."))
您必须添加为您的应用提供的文件,例如this