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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:44:53+00:00 2026-06-12T12:44:53+00:00

I am able to stop my ServiceA(it is started using AlarmManager ) when an

  • 0

I am able to stop my ServiceA(it is started using AlarmManager) when an IntentService is running by sending a broadcast from IntentService to broadcast receiver. I want to Start the same ServiceA again after my IntentService finished his work.

Ex-I have Service SrvA,IntentService IntSrvB and BroadcastReceiver MyBcr.When my IntSrvB running i am able to stop SrvA.My problem is How to Restart SrvA again when my IntSrvB finish his work.

Note-ServA is started using AlarmManager.

  • 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-12T12:44:55+00:00Added an answer on June 12, 2026 at 12:44 pm

    EDIT: Based on your code, you can pass your variables myIntent & myIntent2 into your IntentService class – you can then use them to recreate exact replicas of the pending intents used with the AlarmManager.

    Please note that it looks like you set an Alarm for each intent that repeats once “NOW” and then at intervals after that. You then implicitly start the service again i.e. you start the service twice “NOW”. That looks like a mistake – look at the docs for the AlarmManager.setRepeating() method.


    Original answer below…

    Put this into your IntentService:

    @Override
    protected void onHandleIntent(Intent intent)
    {
        try
        {
            // STOP SERVICE
    
            // DO YOUR WORK HERE
        }
        finally
        {
            // START SERVICE
        }
    
    }
    

    You already have the code to stop the service. You can take the “start service” code from your BroadcastReceiver and put it in the finally block.

    I would not recommend overriding onDestroy() in general on Android.

    NOTE: I don’t think this is the best way to design your app, but I’m answering your question. Personally, I would have a method in my main Service that is able to disable & enable its functionality – and then call that method instead of starting & stopping the service.

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

Sidebar

Related Questions

I need to be able to start/stop a per-session GUI agent from a root
I want to stop the end users from being able to resize a GUI
For security purposes, I want to stop the users from being able to view
I want to stop outgoing call and open the application. The app is able
During the use of my app, the user should be able to start, stop,
I have noticed some applications (like steam) are able to start/stop services as a
I have a service that I need to be able to start and stop
As per my requirement I want to start/stop services over incoming SMS. As per
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For

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.