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

  • SEARCH
  • Home
  • 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 7041413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:02:31+00:00 2026-05-28T02:02:31+00:00

I am creating an app in which on clicking on button user can send

  • 0

I am creating an app in which on clicking on button user can send email.
But I want the task of sending email should be done in Background.
Someone suggested me to use AsyncTask but I am totally unaware of this.
can anybody tell me how to do it ?
I have sendEmail function which takes two string parameters(username , password) and I don’t know how to pass that two string args to AsyncTask and to doInBackground method.
my sendEmail function is

    public void sendEmail(String ownerEmailid, String datapwd )
{
    try {

        GMailSender sender = new GMailSender( ownerEmailid, datapwd );
        sender.sendMail( "This is Subject",   
                         "Hey buddy listen to this station it is awesome",
                         ownerEmailid,   
                         email );
    } catch( Exception e ) {
        Log.e("SendMail", e.getMessage(), e);   
    } 
}

please suggest solution.

  • 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-05-28T02:02:34+00:00Added an answer on May 28, 2026 at 2:02 am

    in onClick call

    new SendEmail(0).execute();
    
    /** Inner class for implementing progress bar before fetching data **/
        private class SendEmail extends AsyncTask<Void, Void, Integer> 
        {
    //if you want to show progress you can show here
    
      //  private ProgressDialog Dialog = new ProgressDialog(yourActivityClass.this);
        @Override
        protected void onPreExecute()
        {
    //           Dialog.setMessage("Doing something...");
       //     Dialog.show();
        }
    
        @Override
        protected Integer doInBackground(Void... params) 
        {
            //Task for sending mail
    
    try {
    
            GMailSender sender = new GMailSender( ownerEmailid, datapwd );
            sender.sendMail( "This is Subject",   
                             "Hey buddy listen to this station it is awesome",
                             ownerEmailid,   
                             email );
        } catch( Exception e ) {
            Log.e("SendMail", e.getMessage(), e);   
        } 
            return 0;
        }
    
        @Override
        protected void onPostExecute(Integer result)
            {
    
            if(result==0)
            {
    //do some thing
            }
    
    // after completed finished the progressbar
     //       Dialog.dismiss();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an app which needs to be opened if a user double
I am in the process of creating an app in which a customer can
I'm creating an app which has the ability for the user to pin a
I'm creating an app which has a text field & go button on top
I am creating a simple app that let's the user view movies after clicking
I'm creating an app which allows the user to manipulate a table structure by
I'm creating an app which communicates alot with a server. I want to make
i am creating an app in which i want to take xmldata using webservices.
I am creating an app which requires internet. I want to use reachability class
I am creating a iPod app which will on multiple devices. For each user

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.