Using Android Intent.ACTION_SEND for sending email

前端 未结 17 1265
野趣味
野趣味 2020-11-29 23:07

I\'m using Intent.ACTION_SEND to send an email. However, when I call the intent it is showing choices to send a message, send an email, and also to

17条回答
  •  迷失自我
    2020-11-29 23:50

    public class MainActivity extends AppCompatActivity {
    
      private EditText edt_email;
      private Button btn_send;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        edt_email = (EditText) findViewById(R.id.edt_email);
        btn_send = (Button) findViewById(R.id.btn_send);
    
        btn_send.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
    
            Intent intent = new Intent(Intent.ACTION_SEND );
            intent.putExtra(Intent.EXTRA_EMAIL , new String[]{"sanaebadi97@gmail.com"});
            intent.putExtra(Intent.EXTRA_SUBJECT , "subject");
            intent.putExtra(Intent.EXTRA_TEXT , "My Email Content");
            intent.setType("message/rfc822");
            startActivity(Intent.createChooser(intent , "Choose Your Account : "));
          }
        });
      }
    }
    

提交回复
热议问题