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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:14:52+00:00 2026-06-13T14:14:52+00:00

Possible Duplicate: How do I pass data from a BroadcastReceiver through to an Activity

  • 0

Possible Duplicate:
How do I pass data from a BroadcastReceiver through to an Activity being started?

In my Android application, I have a main activity called App and a BroadcastReceiver called SmsReceiver. Inside the onReceive() method of SmsReceiver, I want catch an SMS and send its contents back to App. I don’t know how to do this, though. Would this be done with a class inside App? I have tried doing this, and adding that class’s name to the AndroidManifest, but upon trying to call it, the application crashed with an error saying that this class could not be instantiated.

(I am aware that this question has been posted before, but I haven’t seen any satisfying answers on them.)

Edit, to illustrate the solution I tried:

In the AndroidManifest, I added this:

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

In the App class, I added:

public class SmsHandler extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        // Stuff here
    }
}

and

public static final String TEXT_INTENT = "textintent";

I tried to call it using the following code (in SmsReceiver but this made the app crash):

private void forwardSms(Message message, Context context) {
    Intent myIntent = new Intent(MsgWallApp.TEXT_INTENT);

    Bundle myData = new Bundle();
    myData.putString("sender", message.getSender());
    myData.putString("text", message.getText());
    context.sendBroadcast(myIntent);
}
  • 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-13T14:14:53+00:00Added an answer on June 13, 2026 at 2:14 pm

    If you only want to catch the event when your activity is not destroyed, than having the broadcast receiver inside the activity is enough.

    If you want to catch all broadcasts, even when your activity is not started, have a look at Android Services.

    About your specific error, how about pasting it here? Also maybe your code?

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

Sidebar

Related Questions

Possible Duplicate: pass data from Action To Another Action I have a view in
Possible Duplicate: How to pass object from one activity to another in Android I
Possible Duplicate: How do I pass data between activities in Android? I have two
Possible Duplicate: How to pass object from one activity to another in Android While
Possible Duplicate: How do I pass data between Activities in Android application? How would
Possible Duplicate: How to pass a variable / data from javascript to php and
Possible Duplicate: pass callback from python to c++ using boost::python I have to make
Possible Duplicate: Passing data between activities in Android I'm trying to pass a string
Possible Duplicate: How to pass data to detail view after being selected in a
Possible Duplicate: Passing data between asp.net pages how to pass value of TEXTBOX from

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.