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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:19:43+00:00 2026-05-28T11:19:43+00:00

So, I’m streaming music in a separate thread. If I leave the app (

  • 0

So, I’m streaming music in a separate thread. If I leave the app (onPause(), onStop() getting called, etc), the music continues to play, but eventually — after opening other apps and switching between them and going back to the home screen — my app is killed. No crash, just a WIN DEATH and process com.myapp.android has died in logcat. Obviously, it’s legit for apps to be destroyed by the system in order to reclaim resources.

My question is: does running stuff in a thread off of the main (UI) thread mean that it now has less priority as far as the system is concerned? Meaning, is it more likely to be killed than if I run the media player in a Service and even use startForeground() to make the service run in the foreground?

Any thoughts or clarification would be greatly appreciated!

EDIT

Also, part of the documentation on Services confuses me. In pertinent part, it states:

Caution: A service runs in the main thread of its hosting process—the
service does not create its own thread and does not run in a
separate process (unless you specify otherwise). This means that, if
your service is going to do any CPU intensive work or blocking
operations (such as MP3 playback or networking), you should create a
new thread within the service to do that work.

I’ve always ran MP3 playback in a service on the main thread and the UI remained responsive. If I’m supposed to put it in a separate thread as recommended in the above quotation, then won’t I end up back where I started, namely with the media playback occuring off of the main thread, thereby increasing the likelihood that the playback is killed when other apps are opened, etc?

  • 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-28T11:19:44+00:00Added an answer on May 28, 2026 at 11:19 am

    I think most of your question is answered in the Android documentation on Services.

    From the link:

    A foreground service is a service that’s considered to be something
    the user is actively aware of and thus not a candidate for the system
    to kill when low on memory. A foreground service must provide a
    notification for the status bar, which is placed under the “Ongoing”
    heading, which means that the notification cannot be dismissed unless
    the service is either stopped or removed from the foreground.

    To answer your question, yes, running a separate Thread off of an Activity is going to have lower priority than a Service running in the foreground, if the Activity that started the Thread has been stopped/paused.

    Personally, I would recommend doing this in a Service, as this is exactly the sort of thing the Service class has been created for.

    Edit:

    Interesting, what you suggest seems contrary to what I have read (everything is responsive when not using thread in Service). Regardless, it probably should be started in a background thread.

    The thread (a thread that YOU create) won’t die unless the process dies, and that will happen when the runtime decides that resources are needed. Activity‘s can be killed when they are not in the foreground, so their Thread‘s can be destroyed too. If you have a Service marked as foreground, it is less likely to be destroyed, and therefore, you should not have the same problem.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I am writing an app with both english and french support. The app requests

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.