Communicate progress from local Service
<p>An application I'm building uses a local <code>Service</code> 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 <code>pdf</code> copy of a book for offline viewing.</p>

<p>To handle downloads I'm using a locally bound <code>Service</code>. I do not want this <code>Service</code> to run all the time, only when downloading files. So that the <code>Service</code> 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 <code>Intent</code> passed to <code>Context.startService</code>.</p>

<p>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 <code>ProgressBar</code> 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 <code>bookId</code>.</p>

<p>Because I do not want to bind to the service from every <code>Activity</code>, my tentative plan was to use a <code>public static final HashMap</code> on the <code>Service</code> class itself to contain a mapping of <code>bookId</code> to download status, an <code>enum</code> 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.</p>

<p>Additionally I need to retrieve download progress percent from the <code>Service</code>, for a given <code>bookId</code>, 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 <code>Service</code>. My current plan is to use some sort of singleton mediator, that the <code>Service</code> will push updates to, and the views can read from. But I'm not terribly happy with this idea.</p>

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

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