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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:18:17+00:00 2026-06-03T14:18:17+00:00

I have been doing some research on this but found no clear answer. The

  • 0

I have been doing some research on this but found no clear answer.

The functional challenge is:

a) Start an activity with a layout (OK)

b) By Button (labeled START) click ist starts a background service (OK)

c) While the activity can be closed, the background service must continue to run (OK)

d) The background process is still there, I can see it in my notification (OK)

e) The activity restarts from the notification (OK)

f) The activity must connect to the process and get the status of it back. Simply checking if the service is running and set the label of the start-stop-button from (b) to STOP.

e) Hitting the button will stop the service, so that works.

Here are some details:

The connection to my service LogoTimerService is done in the activity like this:

private ServiceConnection mConnection = new ServiceConnection() {

    @Override
    public void onServiceConnected(ComponentName className, IBinder service) {
        // We've bound to LocalService, cast the IBinder and get
        // LocalService instance
        LogoTimerServiceBinder binder = (LogoTimerServiceBinder) service;
        mService = binder.getService();
        mBound = true;
    }

    @Override
    public void onServiceDisconnected(ComponentName arg0) {
        mBound = false;
    }
};

ON RESUME I call this function to actually connect:

private void connectLogoTimerService() {
    Log.i(tag, "-connecting service");

    Intent intent = new Intent(this, LogoTimerService.class);
    startService(intent);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    if (mService!=null) 
        Log.i(tag, "-SERVICE BOUND");
    else
        Log.i(tag, "-Service NOT bound");
}

When I start the application the first time, I get a the second (NOT bound) message.

Why is it not bound? Is it to slow? (It seems like it playing around.)

If I do not destroy the activity the mService is found.

How can I synchronize this, so I can get the status back?

I start AND bind the service. Is this correct?

I can see that the service is running using this code (I found it on this site, thanks):

private boolean isMyServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager
            .getRunningServices(Integer.MAX_VALUE)) {
        if (LogoTimerService.class.getName().equals(
                service.service.getClassName())) {
            return true;
        }
    }
    return false;
}

Thank you very much for your help!

  • 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-03T14:18:19+00:00Added an answer on June 3, 2026 at 2:18 pm

    Answer on your first question is because the bindService is ‘async’. You will enter the if statement before onServiceConnected is called.

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

Sidebar

Related Questions

I have been doing some research about this and have found a few similar
This is a homework problem that I have. I have been doing some research
I have been doing some research lately over my work project, i am trying
We have been doing some research into physically isolating the secure and non-secure sections
I have been doing some research on test driven development and find it pretty
I have been doing some research for using MSMQ. Following 2 gave me fundamental
So I have been doing some research into getting my UTF8 to print correctly.
I have been doing some research on the correct procedure to follow when working
I have been doing some research on ID3V2 tags and Video Formats such as
I have been tasked with doing some planning and research for a home grown

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.