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

  • Home
  • SEARCH
  • 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 8659609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:03:14+00:00 2026-06-12T16:03:14+00:00

I have to make sure that my Service will run until I’ll explicitly call

  • 0

I have to make sure that my Service will run until I’ll explicitly call stopService().
so I should return from onStartCommand() the START_STICKY flag.

also I want that in case my Service will be destroyed by the system because low memory, when the system will re-create it – the onStartCommand() will be called with the same intent originally started the service in the first place.
because this reason – I would like to use the START_FLAG_REDELIVERY flag.
what I described surely can happened (and actually happened to me ones) according to the documentation – http://developer.android.com/reference/android/app/Service.html#ProcessLifecycle

I know I can start the service with startForground(), that prevents the service been candidate for killed by the system when the memory is low, but I prefer not to use this approach, and anyway – according to the documentation: the system still can kill it under extreme low memory pressure.

so it would be perfect if I could return from onStartCommand()
START_STICKY|START_FLAG_REDELIVERY

but according to the documentation it seems like you can use only one of the flags (maybe I’m wrong??).

so is it possible to start somehow service that will work in such a way as I described?

  • 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-12T16:03:15+00:00Added an answer on June 12, 2026 at 4:03 pm

    You cant return multiple values. Instead, I would suggest you to return START_STICKY flag in onStartCommand. But for the first time, save the necessary values of intent’s bundle in a SharedPreference storage. Next time, when your onStartCommand is re-called (after recovering from low memory or whatever reason) and the intent is found to be null, then simply load the values from preferences and keep on going with what ever you want.

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

Sidebar

Related Questions

I have a service that will run every X minutes. If that job takes
I have a user model on which I check to make sure that the
I have been trying to test my application to make sure that all the
I have the below coding, i am make sure that if condition is TRUE,
I have a requirement, where we need to make sure that the document [PDF]
I have two Ajax calls. I need to make sure that a JS function
I have the following code; I want to make sure that submit does not
I have method in a class that I need to make sure is only
I am building a service that will have a 'forgot my password' feature. In
I have service that I need to run every 5 minutes. I already have

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.