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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:59:47+00:00 2026-05-15T02:59:47+00:00

I am trying to use a sendOrderedBroadcast in my Android app. I want to

  • 0

I am trying to use a sendOrderedBroadcast in my Android app.

I want to be able to send the Intent from one of my applications to another and I then want to get data back from the Application that recieves the Intent, in this case a boolean true or false.

Here is the current code:

    Intent i = new Intent();
    i.setAction(GlobalData.PROPOSE_IN_DOMAIN_ROAM_INTENT);
    i.putExtra("com.testnetworks.QCLEVEL", aProposedTheoreticalQoSLevel);
    sendOrderedBroadcast(i, null, null, null, Activity.RESULT_OK, null, null);

Is this the correct way to achieve what I want?

If so what do I use as the resultReceiver* parameter? (3rd parameter)

And then how to I recieve data back from the Broadcast?

I have done a quick google and not come up with any examples, any help or examples greatly appreciated.

UPDATED CODE:


sendOrderedBroadcast(i, null, domainBroadcast, null, Activity.RESULT_OK, null, null);

class DomainBroadcast extends BroadcastReceiver{

    @Override
    public void onReceive(Context arg0, Intent intent) {
        String action = intent.getAction();

        if(GlobalData.PROPOSE_IN_DOMAIN_ROAM_INTENT.equals(action)){
            Log.d("BROADCAST", "Returning broadcast");

            Bundle b = intent.getExtras(); 
            Log.d("BROADCAST", "Returning broadcast " + 
                    b.getInt("com.testnetworks.INT_TEST"));
        }      
    }

    @Override
    public void onReceive(Context context, Intent intent) {
            String action = intent.getAction(); 

            if(GlobalData.PROPOSE_IN_DOMAIN_ROAM_INTENT.equals(action)){

                Bundle b = intent.getExtras();
                int testQCLevel = b.getInt("com.testnetworks.QCLEVEL");
                switch(testQCLevel){
                case 1:
                    Log.d("QCLevel ", "QCLevel = UNAVAILABLE");
                    break;
                case 2:
                    Log.d("QCLevel ", "QCLevel = BELOWUSABILITY");
                    break;
                case 3:
                    Log.d("QCLevel ", "QCLevel = VOICE");
                    break;
                }

                intent.putExtra("com.testnetworks.INT_TEST", 100);

          }

So according to the Doc’s I should recieve 100 back in my DomainBroadcast reciever but it always comes back as 0.

Can anyone see why?

**resultReceiver – Your own BroadcastReceiver to treat as the final receiver of the broadcast.*

  • 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-15T02:59:48+00:00Added an answer on May 15, 2026 at 2:59 am

    You need to get the extra data results Bundle and add your data to it.

    Try something like this:

    public class DemoOrderedBroadcast extends Activity {
        private static String SOMETHING_HAPPENED = "com.example.somethinghappened";
        private static String EXTRA_INTEGER = "extra integer";
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            IntentFilter filter = new IntentFilter(SOMETHING_HAPPENED);
    
            registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    Bundle results = getResultExtras(true);
                    results.putInt(EXTRA_INTEGER, 100);
                    Log.d("DemoOrderedBroadcast",
                            "In Initial Receiver: Put 'extra integer' = 100");
                }
            }, filter);
    
            Intent intent = new Intent(SOMETHING_HAPPENED);
            sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    Bundle results = getResultExtras(true);
                    Log.d("DemoOrderedBroadcast",
                            "In Result Receiver: Got 'extra integer' = "
                                    + results.getInt(EXTRA_INTEGER, -1));
                }
            }, null, Activity.RESULT_OK, null, null);
        }
    }
    

    Which produces the desired output:

    $ adb -e shell am start -n com.example.DemoOrderedBroadcast/.DemoOrderedBroadcast
    Starting: Intent { cmp=com.example.DemoOrderedBroadcast/.DemoOrderedBroadcast }
    $ adb -e shell logcat | grep D/DemoOrderedBroadcast
    D/DemoOrderedBroadcast( 1343): In Initial Receiver: Put 'extra integer' = 100
    D/DemoOrderedBroadcast( 1343): In Result Receiver: Got 'extra integer' = 100
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use Java's regexp I want to match /app, /app/.* , but not
I am trying use the onClick() function in an activity for an android app.
I am trying use a Java Uploader in a ROR app (for its ease
I want to do following things from main thread/process: Communicate to another process using
I am trying use Date Picker and on Select i want to display the
I want use localized strings from resources in xsl template as in aspx page,
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use to selenium with firefox on CentOS from command line like this:
i'm trying use webview to load a image from sdcard i use this path

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.