Android pick and play audio file

This post describes how to start a Service and stop a Service on Button click.

Create your layout in activity_main.xml. Add a Button button1 to pick audio file, another Button button2 to play audio file, a SeekBar to display the duration of song played, and two TextViews to display the duration and name of audio file.

XML

In MainActivity.java add following code.

Java

Now run the app.