在Android中实施Gmail等反馈

时间:2019-12-24 01:49:09

标签: android gmail feedback

我正在以这种方式实现一种简单的方法来在我的应用中发送反馈。

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之类的反馈,添加系统日志截屏不显示我的电子邮件,如图片所示

enter image description here

有解决这个问题的想法吗?

1 个答案:

答案 0 :(得分:0)

尝试一下,这将发送您应用的日志

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("arunabimanyu7@gmail.com")

    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..."))

u必须为您的应用添加文件提供,例如this