FAQ

  1. What do I do if I want to play music?

    You can play some music in the background of your app using the MediaPlayer class. Here is some sample code to show how simple this can be:

    // Create a MediaPlayer object
    MediaPlayer mp = new MediaPlayer();
    // Choose where to load the music from
    mp.setDataSource(musicFileToLoad);
    // Call the prepare method
    mp.prepare();
    // Play some music
    mp.start();

    Take a look at the official documentation for full details at http://developer.android.com/reference/android/media/MediaPlayer.html.

  2. How about if I want to make an actual music playing app where the user can select music from their library to play.

    This is also made easy for us by Android. On the Android Studio palette, you can drag a MediaController widget, which ...

Get Android Programming for Beginners 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.