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 8087841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:54:31+00:00 2026-06-05T18:54:31+00:00

I want an AsyncTask to send an SMS given the parameters. The SMS is

  • 0

I want an AsyncTask to send an SMS given the parameters. The SMS is being sent correctly, but I want to show a ProgressBar until the SMS is sent and then take the user to a new activity. I looked on the internet for examples, but I could not figure out what I want to do with my case. Below is my AsyncTask

public class sendSms extends AsyncTask<Void, Integer, Void>{            

         protected void onPreExecute() {
             pb.setVisibility(View.VISIBLE); //pb is the ProgressBar   
            }

        @Override
        protected Void doInBackground(Void... params) {
             SmsManager sms = SmsManager.getDefault();
             sms.sendTextMessage(phoneNumber, null, message, null, null);       
            return null;                
        }

        protected void onProgressUpdate(Integer... progress){
             //Not sure what to do here
        }

        protected void onPostExecute(){
            Intent intn = new Intent(CurrentActivity.this, NewActivity.class);
            startActivity(intn);
        }           
}

I appreciate any help. Thank you.

  • 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-05T18:54:33+00:00Added an answer on June 5, 2026 at 6:54 pm

    please check the source code.

    public class sendSms extends AsyncTask<Void, Integer, String>{            
    
             protected void onPreExecute() {
                 pb.setVisibility(View.VISIBLE); //pb is the ProgressBar   
                }
    
            @Override
            protected Void doInBackground(Void... params) {
                 SmsManager sms = SmsManager.getDefault();
                 sms.sendTextMessage(phoneNumber, null, message, null, null);       
                return "Done";                
            }
    
            protected void onProgressUpdate(Integer... progress){
                 //Not sure what to do here
            }
    
            protected void onPostExecute(String result){
    if(result.equals("Done"))
            {
                pb.setVisibility(View.GONE);
                Intent intn = new Intent(this, NewActivity.class);
                startActivity(intn);
    }
        }           
    

    }

    I think it help you.

    Thanks

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

Sidebar

Related Questions

Possible Duplicate: AsyncTask block UI threat and show progressbar with delay I want to
I'm using AsyncTask to download an image and want to send the downloaded image
I am using AsyncTask to get data from a server and want to show
I have an asynctask that reads data from a device and then I want
I want to execute an asynctask after finishing the first task. But when printing
I want to put progress bar when object is sent to the server. But
I've got following code in my AsyncTask. The only thing I want the AsyncTask
I am using AsyncTask and want to use getApplication() to work with class Application.
I have an AsyncTask and on the background I want to start Service that
I want to lock back button while my data process. I use AsyncTask to

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.