Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Android Studio Email Intent. Have recipient field filled when opening email client

i'm fairly new to java and i'm having a problem with email intents. I am developing an app and i made an email intent but i dont know how to make sure that the recipient field isn't the result of the user input in an edit text box, i want that removed so it only shows the "subject" and "message" box in the app. i want the recipient field already filled when you tap "send". Here is my code

 editTextSubject=(EditText)findViewById(R.id.editText2);
    editTextMessage=(EditText)findViewById(R.id.editText3);

    send=(Button) findViewById(R.id.button1);

    send.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View arg0) {

            String[] recipients = new String[]{"email@gmail.com"};
            String subject=editTextSubject.getText().toString();
            String message=editTextMessage.getText().toString();





            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, recipients );
            email.putExtra(Intent.EXTRA_SUBJECT, subject);
            email.putExtra(Intent.EXTRA_TEXT, message);

            email.setType("message/rfc822");
            startActivity(Intent.createChooser(email,"Choose an Email client :"));
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Here the code I used to send a new email

   public void contact() {
            final Intent send = new Intent(Intent.ACTION_SENDTO);

            final String email = "youremail@gmail.com";
            final String subject = "subject";
            final String body = "body...";

            final String uriText = "mailto:" + Uri.encode(email) +
                    "?subject=" + Uri.encode(subject) +
                    "&body=" + Uri.encode(body);
            final Uri uri = Uri.parse(uriText);

            send.setData(uri);
            startActivity(Intent.createChooser(send, getString(R.string.settings_email_chooser)));
        }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!