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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:52:11+00:00 2026-05-16T07:52:11+00:00

I have just started using services in Android and I have a made a

  • 0

I have just started using services in Android and I have a made a simple service that is polling a server every 20 seconds.

Now how can I get this data from my main activity (when it is active)?

Alternatively the service could send it back do my main activity (but only if its active). I don’t want to wake up my activity.

I have read SDK examples of “Binding” but I can’t find an example how to actually get something from the service. Just how to start and stop the Binding.

From the example. If I have the “mBoundService” object in my activity how do I get my data from the service method called eg. “pollingData()”?

  • 1 1 Answer
  • 1 View
  • 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-16T07:52:11+00:00Added an answer on May 16, 2026 at 7:52 am

    My suggestion would be to send out a broadcast using sendBroadcast() from the service and then use a BroadcastReceiver as an inner class in your main activity. Depending on your service you can just attach the data to the intent using putExtras() and getExtras()

    Hope this helps!

    A practical example:

    public class x extends Service {
    
    //Code for your service goes here
    
       public talk() {
          Intent i = new Intent();
          i.putExtras("Extra data name", "Super secret data");
          i.setAction("FILTER");
          sendBroadcast(i);
       }
    }
    

    Then in the class the service is talking to:

    public class y extends Activity {
    
       //Code for your activity goes here
    
       BroadcastReceiver br = new BroadcastReceiver() {
          public void onReceive(Intent i) {
             String str = (String) i.getExtras().get("Extra data name").toString();
          }
    
       OnResume() {
          super.OnResume();
          IntentFilter filt = new IntentFilter("FILTER");
          this.registerReceiver(br, filt);
    
          //Do your other stuff
       }
    
       OnPause() {
          super.OnPause();
          unregisterReceiver(br);
       }
    

    Hope this example is about what you are looking for, let me know if you need any more details.

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

Sidebar

Related Questions

I have just started using django-cms so please forgive my newbieness. Every time i
I have just started using JSF 2.0 and faced a warmly welcomed issue. I
I have just started using Sencha Architect, and I have problems doing even the
I have just started using c++ exceptions and want to get it right. What
I have just started using EF and found it cool, but I ran into
I have just started using and am falling in love with MVC design pattern.
i have just started using Moq ver (3.1) and i have read blogs and
I have just started using jQuery and although following code gets the job done,
I have just started using the Data Access Application Block from microsoft. There are
I have just started using C2DM. I prefer to send REGISTRATION intent only once

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.