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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:57:43+00:00 2026-06-07T05:57:43+00:00

I am developing an application where i need to send an sms to a

  • 0

I am developing an application where i need to send an sms to a particular phone number. I can send the sms using following code.

try {
                SmsManager smsManager = SmsManager.getDefault();
                smsManager.sendTextMessage(phoneNo, null, sms, null, null);
                Toast.makeText(getApplicationContext(), "SMS Sent!",
                        Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(),
                        "SMS faild, please try again later!",
                        Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }

Now what i want is the sms should go automatically. The time, at which the message should go automatically, is stored in MySQL database.So i need the code that will keep on checking when that time comes and then send the message to that number automatically. Its a kind of reminder thing. The user will keep a reminder in application eg.; i need to get a message after 1 hour. So after 1 hour the message should come. PLz help??

Finally i got it.

/** Code For reminder is here */
            int time=Integer.parseInt(answer);
            int num = (int)System.currentTimeMillis();  
            Intent intent = new Intent(getApplication(), MyBroadcastReceiver.class);
            intent.putExtra("phoneNo",phoneNo);   
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            calendar.add(Calendar.MINUTE, time);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(
                getApplicationContext(), num, intent, 0);
            AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
            alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
                + calendar.getTimeInMillis() , pendingIntent);
            Toast.makeText(getApplication(), "Alarm set in " + time + " minutes",
            Toast.LENGTH_SHORT).show();
            /** Code for reminder is over */

And my reciever code is

 public void onReceive(Context context, Intent intent) {
    String sms= "Your turn is about to come. Please be ready. Thank You";
    String phoneNo;
    Bundle extrasBundle = intent.getExtras();
    phoneNo=extrasBundle.getString("phoneNo");
    try {
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNo, null, sms, null, null);
        Toast.makeText(context, "SMS Sent to " + phoneNo,Toast.LENGTH_LONG).show();
        } catch (Exception e) {
        Toast.makeText(context,"SMS faild, please try again later!",Toast.LENGTH_LONG).show();
        e.printStackTrace();
        }

}

Just in case someone might need this… Thanku

  • 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-07T05:57:44+00:00Added an answer on June 7, 2026 at 5:57 am

    use AlarmManager for this purpose. Create a receiver, register it in manifest file.
    with alarmaManager set an Alarm after particular time.
    put your SendSMS code into Receiver’s on receive.

    Edit : I answered this long back, it is not suitable for current scenarios, please read this blog for better alternatives Background schedulers instead.

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

Sidebar

Related Questions

Iam developing one application.In that iam using the uilabels.And my problem is i need
Introduction to the situation For an application I'm currently developing, I need to code
I am developing an application in Django 1.3.1 on windowsxp,sp2. I need to send
I am currently developing an application in C# using WPF. I need the program
I am developing one iPhone application where I need to send some data (in
I'm developing an iPhone application and I need to send some information to an
I'm developing a Blackberry OS 5 + application and I need to send some
I am developing a Android Application, In which I need to send voice by
I am currently developing an application and I need to be able when pressing
I am developing an application were I need to transform XML documents that look

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.