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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:59:17+00:00 2026-05-15T06:59:17+00:00

In Virgil Dobjanschi’s talk, Developing Android REST client applications (link here ), he said

  • 0

In Virgil Dobjanschi’s talk, “Developing Android REST client applications” (link here), he said a few things that took me by surprise. Including:

  • Don’t run http queries in threads spawned by your activities. Instead, communicate with a service to do them, and store the information in a ContentProvider. Use a ContentObserver to be notified of changes.

  • Always perform long running tasks in a Service, never in your Activity.

  • Stop your Service when you’re done with it.

I understand that he was talking about a REST API, but I’m trying to make it fit with some other ideas I’ve had for apps. One of APIs I’ve been using uses long-polling for their chat interface. There is a loop http queries, most of which will time out.

This means that, as long as the app hasn’t been killed by the OS, or the user hasn’t specifically turned off the chat feature, I’ll never be done with the Service, and it will stay open forever. This seems less than optimal.

Long question short:

For a chat application that uses long polling to simulate push and immediate response, is it still best practice to use a Service to perform the HTTP queries, and store the information in a ContentProvider?

  • 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-15T06:59:18+00:00Added an answer on May 15, 2026 at 6:59 am

    Don’t run http queries in threads
    spawned by your activities. Instead,
    communicate with a service to do them,
    and store the information in a
    ContentProvider. Use a ContentObserver
    to be notified of changes.

    I have yet to view the presentation, though I have reviewed the slides. I have serious reservations about the ContentProvider portion of the proposed architecture.

    Always perform long running tasks in a
    Service, never in your Activity.

    Everybody has their pet “always” and “never” statements, myself included. I would hesitate to put this in the “always” category. Using a Service as a home base of long-running tasks is a fine strategy, but it too has its issues (e.g., in a screen rotation, unbindService() will destroy the Service before the next bindService() kicks in, if there are no other bound connections, leaving you with gobs and gobs of connection bookkeeping if you have a complex app).

    For a chat application that uses long
    polling to simulate push and immediate
    response, is it still best practice to
    use a Service to perform the HTTP
    queries, and store the information in
    a ContentProvider?

    It is a practice. IMHO, the jury is still very much out as to whether it is a best practice.

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

Sidebar

Ask A Question

Stats

  • Questions 437k
  • Answers 438k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I believe that ValidateRequest is a property that you can… May 15, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer If you want the links to neighbour the title, use… May 15, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer May be you will find useful XamlWriter http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlwriter.aspx . It… May 15, 2026 at 4:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.