O'Reilly logo

Android 5 Programming by Example by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capturing and playing video

Using native apps to capture video content from within our own apps is achieved in an almost identical way, to the one we just applied. The main difference is that when dealing with video content a lot of the functionality is provided by the purpose-built widget, the VideoView. We will also add video control buttons with the MediaController and see how to pause a video when our app is sent to the background. Follow these steps to build a simple video app:

  1. Start a new Android Studio project.
  2. Add the feature uses and permissions we included in the last exercise to the manifest.
  3. Open the activity_main.xml file and replace the TextView with this VideoView:
    <VideoView android:id="@+id/video_view" android:layout_width="match_parent" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required