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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:44:32+00:00 2026-05-31T23:44:32+00:00

I have a service that also contains an activity the problem is sometimes it

  • 0

I have a service that also contains an activity the problem is sometimes it gets shut down by the operating system.

How can I prevent that from happening?

  • 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-05-31T23:44:33+00:00Added an answer on May 31, 2026 at 11:44 pm

    Not sure what you mean by "service that contains an activity".

    The OS can and will shut down services based on demand for memory. How often this happens depends on what you have running on your device, and the amount of memory that your device has.

    To try to minimize this, you can call Service.startForeground(). Please read the javadocs for the proper usage, and please look at stopForeground() as well.

    Note that this is still no guarantee. You must author your app to gracefully handle when your service is destroyed. Please read up on the Service lifecycle to understand how to handle this.

    Even if you could keep your service running at all times, it would be a bad idea. This is not a personal computer plugged in to AC power. A service that is perpetually running will greatly effect the battery life of the device.

    • 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 contains a map: static Map cargosMap = ['1':'item1','2':'item 2','3':'item
I have on Service that must communicate with an Activity (MyActivity) through a BradcastReceiver.
I have a REST service that returns a list of objects. Each object contains
I have created a test service with a method that contains a very long
I have a project that has a web service reference. I also have an
I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer()
I have a mysql table that contains words joined by underscores and also words
I have a WF4 Service with a flowchart as the root activity. It contains
i've got the following problem. I've got web-service that uses Jersey, it can produce
I have a service that I would like it to become single instance, because

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.