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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:17:11+00:00 2026-05-30T16:17:11+00:00

I’m creating a chat app and I am wondering if I should use a

  • 0

I’m creating a chat app and I am wondering if I should use a service and how it will affect the lifecycle of my app. I understand that the Android OS can destroy my app if there isn’t enough memory. My question: do apps that only use Activities and Receivers get restarted if Android destroys them or do I need a STICKY Service for this? I’ve created apps with both, so I have somewhat of an idea, but I just want to make sure.

Second, http://developer.android.com/reference/android/app/Service.html says:

Note that services, like other application objects, run in the main
thread of their hosting process. This means that, if your service is
going to do any CPU intensive (such as MP3 playback) or blocking (such
as networking) operations, it should spawn its own thread in which to
do that work.

My application has a long running thread (AsyncTask) that does the reading from the server (and constantly blocking). Is it a good idea to leave my app as it is, without a service and use the AsyncTask instead? How will this affect the lifecycle of an app if Android chooses to close my app? Is it good practice to have a long running service if there doesn’t need to be, as in, should I make a STICKY Service anyway? I noticed a lot of chat and txt msg apps use a sticky service. I’m just trying to think if my app would need one.

Thanks again in advance!

  • 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-30T16:17:12+00:00Added an answer on May 30, 2026 at 4:17 pm

    Basically, a service allows to run a task that is not bound to a single activity lifecycle.

    For instance you could play music inside of a single activity using normal objects. But if you want your app to play music and allow users to go in and out from all your activities, then you need a service.

    If your app has multiple activites and you want your chat client to still listen to sockets (and I bet you do want that), then you should write a service.

    If you want users to know that a service is running, then your service your service should go to foreground and allow interaction via the notification bar.

    If you want your activities to communicate with your service, then you should bind your service from within your activities.

    And last, you should provide a clear way for users to stop your service as this process will no longer be tied to your app lifecycle and you must explicitly call its stop method or call stopService or make the service call stopSelf on itself. Then provide your users an easy way to stop the service.

    You will also need to get a powerlock and most probably a wifi lock for your service so that it is not stopped by the device going to sleep and the connection to the net is preserved for your service when your application is cleaned by android.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
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

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.