Send Email Intent

前端 未结 30 3274
忘掉有多难
忘掉有多难 2020-11-22 07:27
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(\"text/html\");
intent.putExtra(Intent.EXTRA_EMAIL, \"emailaddress@emailaddress.com\");
intent.putExtr         


        
30条回答
  •  隐瞒了意图╮
    2020-11-22 07:57

    A late answer, although I figured out a solution which could help others:

    Java version

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    emailIntent.setData(Uri.parse("mailto:abc@xyz.com"));
    startActivity(Intent.createChooser(emailIntent, "Send feedback"));
    

    Kotlin version

    val emailIntent = Intent(Intent.ACTION_SENDTO).apply { 
        data = Uri.parse("mailto:abc@xyz.com")
    }
    startActivity(Intent.createChooser(emailIntent, "Send feedback"))
    

    This was my output (only Gmail + Inbox suggested):

    I got this solution from the Android Developers site.

提交回复
热议问题