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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:10:40+00:00 2026-06-11T20:10:40+00:00

I am learning how to send SMS in android, have seen the code as

  • 0

I am learning how to send SMS in android, have seen the code as below:

public class SMSReceiver extends BroadcastReceiver
{
   @Override
   public void onReceive(Context context, Intent intent)
   {
   //---get the SMS message passed in---
   Bundle bundle = intent.getExtras();
   SmsMessage[] msgs = null;
   String str = “”;
   if (bundle != null)
   {
      //---retrieve the SMS message received---
      Object[] pdus = (Object[]) bundle.get(“pdus”);
      msgs = new SmsMessage[pdus.length];
      for (int i=0; i<msgs.length; i++){
         msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
         str += “SMS from “ + msgs[i].getOriginatingAddress();
         str += “ :”;
         str += msgs[i].getMessageBody().toString();
         str += “\n”;
   }
    //---display the new SMS message---
   Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
  }
  }
}

Now my question is how do I know what are the contents of Intent object that are passed into onReceive function? As below:

Object[] pdus = (Object[]) bundle.get(“pdus”);

How do I know there is a “pdus” key in the bundle object?
I can’t find any clue in the API doc, anyone know where is the related information located?

I don’t only want to know what the SMS intent pass into onReceive function, but also the other system related Intent, but I can’t locate any related information in the API doc. I wonder does the information really exist?

  • 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-11T20:10:41+00:00Added an answer on June 11, 2026 at 8:10 pm

    You can check if the bundle contains a Key value pair with key pdus using bundle.containsKey("pdus") which returns true if there are any Protocol Data Units (PDUs which in your case are SMSes).

    So, the check for processing the PDUs should be if (bundle != null && bundle.containsKey("pdus"))

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

Sidebar

Related Questions

Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I'm learning Ajax at the moment. The code below basically receives the echo from
While learning c#, I have picked up the implication from reading other people's code
Learning some VBA. So far, I've constructed this piece of code which should allow
I am currently learning about widgets in Android. I want to create a WIFI
I am slowly learning Python and thumbing through the tutorials. I feel I have
I am learning Java and want to create my own IRC client. I have
I'm learning c++ and got the project to send a pascal's triangle to output
For test and learning purpose, Is it a console available to send http request
I'm currently learning to develop for Android and I'm having a somewhat hard time

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.