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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:41:51+00:00 2026-05-31T20:41:51+00:00

I have an AlarmReceiver class which executes when alarm rings at a particular time

  • 0

I have an AlarmReceiver class which executes when alarm rings at a particular time (set in alarm)

I am sending sms inside AlarmReciever class but I am not able to register the reciever for SMS Sent.

here is the code

                  private int sendSMS(String messageToSend,String contactsToSend,Context context)
       {        
                StringTokenizer  tok=new StringTokenizer(contactsToSend);
                int n=tok.countTokens();
                String SENT = "SMS_SENT";
                String DELIVERED = "SMS_DELIVERED";
                final AlertDialog dialog = new AlertDialog.Builder(context).create();

                PendingIntent sentPI = PendingIntent.getBroadcast(context, 0,new Intent(SENT), 0);

                //---when the SMS has been sent---
                **/*registerReceiver(new BroadcastReceiver**(){
                    @Override
                    public void onReceive(Context arg0, Intent arg1) {
                        switch (getResultCode())
                        {
                                case Activity.RESULT_OK:
                                    break;

                                case SmsManager.RESULT_ERROR_GENERIC_FAILURE:

                                    break;
                                case SmsManager.RESULT_ERROR_NO_SERVICE:

                                    break;
                                case SmsManager.RESULT_ERROR_NULL_PDU:

                                    break;
                                case SmsManager.RESULT_ERROR_RADIO_OFF:

                                    break;
                        }
                        return;
                    }
                }, new IntentFilter(SENT));*/



        SmsManager sms = SmsManager.getDefault();
        String phoneNumber;
        for(int i=0;i<n;i++)
        {
                phoneNumber=tok.nextToken();
                sms.sendTextMessage(phoneNumber, null, messageToSend, null,null); 
        }
        return 1;

      }

when i remove the comment from line (in bold) it gives error.
So how cam i register a reciever to check whether the sms was sent or not.

  • 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-31T20:41:52+00:00Added an answer on May 31, 2026 at 8:41 pm

    instead of registering reciever you can create a service like this

      public class SMSObserver extends BroadcastReceiver 
        {
            static final String ACTION ="android.provider.Telephony.SMS_SENT";
    
            @Override 
            public void onReceive(Context context, Intent intent) 
            { 
                if (intent.getAction().equals(ACTION)) 
                {
                         //your action code here
                }            
            }
        }
    
    but if you want register reciever you can use in your onCreate()
    
     // SendSmsObserver smsObeserver = (new SendSmsObserver(new Handler()));
           // ContentResolver contentResolver = this.getContentResolver();
           // contentResolver.registerContentObserver(Uri.parse("content://sms"),true, smsObeserver);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeating alarm set, my problem is that after cancelling it doesn't
In my alarm application, I take time from time picker and set it in
I have the following code. I set up and alarm in HelloAndroid2.java, and after
I have a small application which can be used to set reminders for future
I'm trying to set up an alarm receiver right after booting. Therefore, i have
have not tested on windows. but in ubuntu when u disconnect from the network,
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
I have inserted an event in a calendar. The time of event created must
I'm building an alarm application. I have successfully implemented basic alarm functions. Calendar calendar

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.