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

  • Home
  • SEARCH
  • 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 7447569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:39:10+00:00 2026-05-29T12:39:10+00:00

in the C2DM sample code from google, when a notification recived in BroadcastReceiver they

  • 0

in the C2DM sample code from google, when a notification recived in BroadcastReceiver they call :

setResult(Activity.RESULT_OK, null /* data */, null /* extra */);

I didnt know what the setResult do. this is what they say in Android docs :

Change all of the result data returned from this broadcasts; only
works with broadcasts sent through Context.sendOrderedBroadcast. All
current result data is replaced by the value given to this method.

Can somebody explain what they mean and why i need to call it?

Complete code :

public class C2DMBaseReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        C2DMReceiver.runIntentInService();
        setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
    }
}
  • 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-29T12:39:12+00:00Added an answer on May 29, 2026 at 12:39 pm

    The setResult(...) method in BroadcastReceiver, its more than anything for tracking purposes.

    If you are familiarised with the Activity‘s method setResult(...), you can think of this method in broadcast in the same way. But instead of getting a callback method like onActivityResult(int requestCode, int resultCode, Intent data) in the case of activities, broadcast setResult(...) method is used to keep track of the results of the broadcasts in a certain order, that’s why the documentation says:

    Only works with broadcasts sent through Context.sendOrderedBroadcast. All current result data is replaced by the value given to this method.

    Which means that you can make use of the methods getResultCode(), getResultData() or getResultExtras() to know how things went during the execution of the onReceive(Context, Intent) method in all the different BroadcastReceivers registered to handle your broadcast. So you can know the result of the code execution in the previous BroadcastReceiver called before the one currently executed along all the receivers.

    It says only Context.sendOrderedBroadcast() because a regular call to sendBroadcast(...) method might not wait for 1 receiver to complete its execution before starting another thread to execute code in other receiver listening the same intent as well.

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

Sidebar

Related Questions

My app is using Google's C2DM (push notification) to notify users about new activity
I directly copied all three C2DM classes into my project from Google Code's ChomeToPhone
I have implemented PushNotification Using C2dm. I am getting notification from c2dm also. My
C2DM registration from my android app fails with an error 'SERVICE_NOT_AVAILABLE'. From what i
I am implementing C2DM for push notification in an android application, it need at
I am using C2DM application,I got registered in Google & the app is running
i'm trying to use C2DM client with this tutorial:http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html I'm using this code for
When you sign up for C2DM with a Google account, you specify the name
I am using android-c2dm, and my device successfully receives messages from it. I want
I signed up with C2DM with Google. How long does it take for them

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.