Background Audio Playback

So far we have concentrated on building applications that are centered around being in the foreground and have their user interface in front of the user. In the last chapter, we looked at how to add audio playback capabilities to those types of applications.

What happens, though, if we want to build an application that plays music or audio books, but we would like the user to be able to do other things with the phone while continuing to listen? We might have some trouble making that happen if we limit ourselves to just building activities. The Android operating system reserves the right to kill activities that aren't in the front and in use by the user. It does this in order to free up memory to make room for other applications ...

Get Pro Android Media: Developing Graphics, Music, Video, and Rich Media Apps for Smartphones and Tablets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.