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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:35:28+00:00 2026-06-14T03:35:28+00:00

I am having a little problem. I can’t get my broadcast receiver to show

  • 0

I am having a little problem. I can’t get my broadcast receiver to show any toast messages. Maybe I can’t get it triggered somehow but my sender works. I want to know if it is even triggering.

Main class

 public class Main_Activity extends Activity {


Button buttonSend;
EditText textPhoneNo;
EditText textSMS;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
   Button  buttons = (Button) findViewById(R.id.gett);
    buttonSend = (Button) findViewById(R.id.buttonSend);
    textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo);
    textSMS = (EditText) findViewById(R.id.editTextSMS);
    EditText edt = (EditText)findViewById(R.id.reciving);


    buttons.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
        //  EditText edt = (EditText)findViewById(R.id.reciving);
        //  SmsReceiver obj = new SmsReceiver();
        //  String test = obj.number2;
        //    edt.setText("you stupid result "+test);

        }
    });

    SmsReceiver obj = new SmsReceiver();
//  String test = obj.number2;
 //   edt.setText("you stupid result "+test);





  buttonSend.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub

        String phoneNo = textPhoneNo.getText().toString();
        String sms = textSMS.getText().toString();

        try{
            SmsManager  smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(phoneNo, null, sms, null, null);


        }catch (Exception e)
        {
            System.out.println("Not send");
        }





    }
})  ;


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
 }

SmsReceiver class:

  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();
    }                         
}
 }

Mainifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dom.example.sms_exp"
    android:versionCode="1"
    android:versionName="1.0" >

<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Main_Activity"
        android:label="@string/title_activity_main_" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <receiver android:name=".SmsReceiver" >
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>

    <activity
        android:name=".SmsReceiver"
        android:label="@string/title_activity_send_activity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</manifest>

Please help, I have a project to submit tomorrow.

  • 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-14T03:35:29+00:00Added an answer on June 14, 2026 at 3:35 am

    if you want to your application receive SMS Broadcast then you must include following permission in manifast

    <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    

    and change your SmsReceiver code as:

    public class SmsReceiver extends BroadcastReceiver
     {
      @Override
        public void onReceive(Context context, Intent intent) 
        {
           if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))
               {
                  //put your code here....
               }
           else{
                 // do something here...
               }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a little problem with inheritance in C++ that I can't quite figure
I'm having a little problem with an URL. I hope you can help me
Hey all, would appreciate any help with a little problem im having. Basically my
I am having a little problem how can I turn the following code into
i'm having a little problem with jquery/javascript countdown and i'm hoping you can help
I am having a little problem with Relative Layouts. I'm doing a project in
I'm having a little problem with the auto-resizing feature! I've already proficiently triple-checked (with
I'm having a little problem with jQuery: I'm having .submit() defined on a form,
I'm having a little problem with nginx and the Perl FCGI module. I have
I'm having a little problem with Merging dictionaries in my WP7 application, The app

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.