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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:37:09+00:00 2026-05-14T21:37:09+00:00

An application I’m building uses a local Service for downloading files from the web

  • 0

An application I’m building uses a local Service for downloading files from the web to the phone’s SD card. In this app users can browse lists of books, and read them while online. A user can also download a pdf copy of a book for offline viewing.

To handle downloads I’m using a locally bound Service. I do not want this Service to run all the time, only when downloading files. So that the Service can shut itself down when its tasks are complete, I am not binding to the service, rather I’m sending an “enqueue for download” command through the Intent passed to Context.startService.

Books available for download are shown in a list. A user can choose to download a book by clicking on its row in the list. On download, I need to show download progress using a ProgressBar on the actual book list row. I need to also show, on the rows, if a book is enqueued for download, or if its download has completed or failed. The books can be shown in different activities throughout the application–in search, or in the user’s list of favorite books, for example. When the books are shown in different places, these are not the same objects, but they are uniquely identified by their bookId.

Because I do not want to bind to the service from every Activity, my tentative plan was to use a public static final HashMap on the Service class itself to contain a mapping of bookId to download status, an enum of enqueued, downloading, cancelled, etc. Each book view, when displayed, would check this static HashMap, and if the bookId is in the map, retrieve and display its status. I don’t particularly like this idea, but at the moment it’s the only way I can think of to retrieve status from the Service without having to bind to it and start it.

Additionally I need to retrieve download progress percent from the Service, for a given bookId, if it is the active download. Again I’d rather not bind to the service from every activity, so I’m not sure how to go about retrieving current progress from the Service. My current plan is to use some sort of singleton mediator, that the Service will push updates to, and the views can read from. But I’m not terribly happy with this idea.

The reason I’d like to avoid binding to the Service from each Activity is 1.) I’m already running another Service and 2.) binding is verbose and I’d like to avoid needing to pass around a reference to the Service (but admittedly this isn’t too much of a problem).

Perhaps binding to the local Service isn’t expensive enough to warrant this other setup? Should I not be concerned about binding to it from each Activity? Maybe this is a non-issue?

  • 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-14T21:37:09+00:00Added an answer on May 14, 2026 at 9:37 pm

    The reason I’d like to avoid binding
    to the Service from each Activity is
    1.) I’m already running another Service

    Then consider combining the two.

    2.) binding is verbose and I’d like to avoid needing to pass around a
    reference to the Service

    Each activity should have its own connection to the service.

    Perhaps binding to the local Service
    isn’t expensive enough to warrant this
    other setup?

    The act of binding to a local service is dirt cheap.

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

Sidebar

Related Questions

Application : HTA (therefore IE) This is an application that uses SendKeys to populate
Application is running in my local system app.config file <add key=dbconn value=Data Source=(local);database=VTech;User ID=sa;Password=sa;
My application is connecting to a web service rpc/encoded. Im using Axis 1.4. When
Application.Run(form); Actually I tried to call this from my project. I got this exception.
My application is allowed users to upload jpeg/png files.I must to detect files with
Application.Run(new Main()); This line gives TypeInitializationException was unhandled after I switched from 3.5 to
Application requests KML data through AJAX from server. This data is stored in javascript
Application db connection in web service. i haveto connect the db using that web
Application ID in appengine is configured in appengine-web.xml: <?xml version=1.0 encoding=utf-8?> <appengine-web-app xmlns=http://appengine.google.com/ns/1.0> <application>myid</application>
Application pool for my web service has Identity set to myDomain\myUser. When I run

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.