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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:44:59+00:00 2026-06-02T09:44:59+00:00

i want to pass some information from the received message when i receive it

  • 0

i want to pass some information from the received message when i receive it such as the content of the message or the source number of it, and i want to put that information in a button on when a certain condition is true not oncreate, am building messaging application so i want to store my received message in “inbox” how can i do that?
Ps. my onreceive method in a class extends broadcastReceiver and my other class extends activity
thanks in advance!
here is my first class where i extends broadcastreceiver

public class Re extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
 {
 Bundle bundle = intent.getExtras();       
SmsMessage[] msgs = null;
 String address="";
    String body="";
    long time = 0;
    if (bundle != null)
    {
        //---retrieve the SMS message received---
        Object[] pdus = (Object[]) bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];
 address= msgs[i].getOriginatingAddress();
            body=msgs[i].getMessageBody().toString();
            time=msgs[i].getTimestampMillis();
}   

}

and here is my second class where i extends activity

public class ThirdView extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.third);
    }
}
  • 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-02T09:45:01+00:00Added an answer on June 2, 2026 at 9:45 am

    If you want to have access to your activity from Receiver’s onReceive – then you should define BroadcastReceiver as inner class of the Actvity and register it programmatically (in onStart method, and unregister in onStop);

    public class ThirdView extends Activity {
    
        private static final IntentFilter intentFilter = 
            new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
    
        TextButton myButton;
    
        BroadcastReceiver receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
    
                SmsMessage[] messages;
                //read parse pdus data from intent and pupulate messages array
                //...
    
                //update the button
                if(messages.length > 0) {
                    myButton.setText(messages[0].getOriginatingAddress());
                }
            }
    
        };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.third);
            myButton = (TextButton) findViewByiD(R.id.myButton);
        }
    
        @Override
        protected void onStart() {
            super.onStart();
            registerReceiver(receiver, intentFilter);
        }
    
        @Override
        protected void onStop() {
            unregisterReceiver(receiver);
            super.onStop();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple bookmarklet to pass some information from javascript to
I'm playing with the flickr api and php. I want to pass some information
I want to pass some values from my Game extends Activity to Screen extends
I want to pass around some values in an array that will always be
I want to pass an uninitialized object pointer to some method. Within that method
so i am using json to pass some information from one place to another...
I want to pass some arguments to the my Javascript template in Rails3 application
I am writing an android app. I want to pass some data across the
I want to pass a string that contains few words to jQuery when click
I want to pass parameters from PHP Command Line Interface, and then read in

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.