Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:10:59+00:00 2026-06-17T04:10:59+00:00

I am relatively new to Android programming, but have had experience in Java and

  • 0

I am relatively new to Android programming, but have had experience in Java and other coding languages. As part of a program that I am currently making, I want to be able to send a pre-defined email when a button is pressed. I am currently looking at this code:

Sending Email in Android using JavaMail API without using the default/built-in app

I am currently able to start an intent to start the MailSenderActivity.class. However, I am not able to understand how that is able to send an email through the GmailSender.class. I believe that I am misunderstanding how to use the code provided. Am I supposed to create two separate intents that will start both activities up, one after each other, in the code on the home page, as below? If not, how would I do it?

public void SendEmail(View v) {
    Intent i = new Intent(getBaseContext(), MailSenderActivity.class);    
    Intent j = new Intent(getBaseContext(), GMailSender.class);       
    startActivity(i);
}

Also, I am wondering about the defined spaces for to/from, subject, body and the like in the code. I see that the MailSenderActivity.class has

                try {   
                GMailSender sender = new GMailSender("username@gmail.com", "password");
                sender.sendMail("This is Subject",   
                        "This is Body",   
                        "user@gmail.com",   
                        "user@yahoo.com");

Are the user@gmail.com and user@yahoo.com both the recipients of the email? And are there any other places in the code where I am supposed to define the contents of the email?

Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:11:00+00:00Added an answer on June 17, 2026 at 4:11 am

    Scroll down and read the rest of the answer, you’ll see that the sendMail() method gives all the clues:

    public synchronized void sendMail(String subject, String body, String sender, String recipients) 
    

    So:
    "user@gmail.com" is the sender (From field).

    "user@yahoo.com" is the recipient (To field). You can specify more with commas, eg

    "user@yahoo.com,user_2@gmail.com"
    

    You would also see that GMailSender is just a class, not an Activity. Therefore, it does not need an Intent; just instantiate the class. Also, MailSenderActivity is a code sample demonstrating the implementation of GMailSender. You do not have to use it.

    Eg

    public void SendMail (View v) {
      try {   
        GMailSender sender = new GMailSender("your_username@gmail.com", "password");
        sender.sendMail("Subject",   
                        "Email body",   
                        "Fromfield@gmail.com",   
                        "toField@example.com");   
      } catch (Exception e) {   
        Log.e("SendMail", e.getMessage(), e);   
      } 
    }
    

    Also keep in mind Java naming conventions state that methods should start with a lowercase letter. You should adhere to those conventions and refactor your code appropriately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Java programming / Android development - but I have been
Im relatively new to the Android world but I have a quick question. I
I'm relatively new to Android programming, and I need a control that holds text
I'm relatively new to Android but I just cant google this. I have following
I am relatively new to Android development but I do have a pretty good
i am relatively new to Android programming. i have gone through a lot of
I am a relatively new Android developer but have gotten pretty familiar with the
Relatively new to Java and Android programming can anybody help as to why I'm
I have a .net development background but relatively new to Java world. We have
I am relatively new to Android Animation and Gestures. I have 15 images that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.