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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:38:42+00:00 2026-06-11T23:38:42+00:00

I have an application with a Service registered in the AndroidManifest to start up

  • 0

I have an application with a Service registered in the AndroidManifest to start up at boot time. I do this via an Intent Receiver for BOOT_COMPLETED, and this works fine. However, if the user is starting the app right after installation, I’d like to start off the Service from my main Activity since it may not be running.

I’m not sure of the best way to do this. I know I can call startService() from the activity, and that works, but then I can have multiple instances of the service running. I don’t want to stop the service first, becusae if it’s running, I just want that instance to keep running. The service could be in the middle of a task and I don’t want it to stop.

In Activity:

Intent serviceIntent = new Intent();
serviceIntent.setAction(MessageReceiverService.ClassName);
startService(serviceIntent);

Android Manifest registeing intent:

<receiver android:name="com.app.proto1.service.StartupIntentReceiver" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />

        <category android:name="android.intent.category.HOME" />
    </intent-filter>
</receiver>

My Service overload methods:

@Override
public IBinder onBind(Intent arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public void onCreate() {
    super.onCreate();

    Log.d(Tag, "onCreate()");
}

@Override
public void onDestroy() {
    super.onDestroy();
    Log.d(Tag, "onDestroy()");
}

@Override
public void onStart(Intent intent, int startId) {

    super.onStart(intent, startId);     
    Log.d(Tag, "onStart()");
    this.registerReceiver(new SmsReceiver(), new IntentFilter(SMS_ACTION));
}   

Is there a way I can check if the service is already running and not start it again, and without destroying the existing one?

  • 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-11T23:38:43+00:00Added an answer on June 11, 2026 at 11:38 pm

    Well if your Service is already running and you try to start service again, there will be no new instance created for the Service it will consider the previous running instance only. So, there is nothing to worry in that case. If you call the Service while its running its onStartCommand(Intent, int, int) will be called and not onCreate().

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

Sidebar

Related Questions

I have registered a custom conversion service in a Spring 3 application. It works
In my application, I have registered a broadcast receiver to receive the system intent
I have a WCF service application and in this app I am doing calls
I have a windows service application which works using remoting. It is used to
I have a service which is binded to application context like this: getApplicationContext().bindService( new
My application have a service and an activity. Sometimes the service will send a
I have an service application that reads a config file containing a list of
I have to map a REST Webservice URL like http://server:8080/application/service/customer/v1 to createCustomer method in
I have a Windows Service application which uses a Threading.Timer and a TimerCallback to
I have a WCF service application with most basic settings working properly on my

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.