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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:08:47+00:00 2026-06-08T09:08:47+00:00

I’ve created an Started Service from an activity. I’m curious about: what happens if

  • 0

I’ve created an Started Service from an activity. I’m curious about: what happens if the activity gets destroyed? Does the service still run? (I think it runs!)

Then when the activity is re-created, is there any way to communicate with that service? I just need to know whether the service is still running, if running, then I want to pass a reference of the activity to the service.

  • 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-08T09:08:49+00:00Added an answer on June 8, 2026 at 9:08 am

    Okay, a comment isn’t big enough. Here’s some code I use to start a service. Following the start service is a function I use to determine if the service is running. The class DownloadDatabase extends IntentService. The service downloads a 70 megabyte SQLite database that was created externally to Android.

     Intent intentService = new Intent(this, DownloadDatabase.class);
     startService(intentService);
    

    The following function checks to see if the service is already running. It is coded as a function because I call it from other routines that do other verifications if is not running.

    private boolean isMyServiceRunning() {
        ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        for (RunningServiceInfo service : manager
                .getRunningServices(Integer.MAX_VALUE)) {
            if ("com.hodsonssoftwarellc.nutritionexplorer.DownloadDatabase"
                    .equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;
    }
    

    You will also need the following permission in your manifest:

     uses-permission android:name="android.permission.GET_TASKS"
    

    What is happening in the isMyServiceRunning function is as follows:

    1. The Activity Manager is acquired.
    2. A list of tasks that are currently running is retrieved and used as the argument in the special case for loop.
    3. As each task is retrieved from the list, the task name is compared to my fully qualified class name for the download service.
    4. If a match is found, the function returns true. Otherwise it returns false.

    So, in answer to your question, yes, you can check to see if it running from your task that starts it. Even if you exit the task and start it again. You can also check if is running from a different activity or app.

    Note: This code was written for 2.x compatibility. If you are doing a download in version 3 or higher, use the download manager instead of writing your own download service.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.