Android Photo and Video Programming

jim-wilson-v5

Welcome to this review of the Pluralsight course Android Photo and Video Programming by Jim Wilson.

Jim has over 30 years of software engineering experience, with the past 15 years heavily focused on creating mobile device and location-based solutions. He has co-founded multiple software-related startups and has served in a consulting role at several more.

After nearly a decade as a Microsoft Device Application Development MVP, Jim now focuses on developing Android and iOS device applications. Jim’s passion is mentoring software developers. He blogs at hedgehogjim.wordpress.com.

Improving User Interface Design with Android Fragments is the 8th course in the Pluralsight learning path for Android, and this month I am reviewing every course in this learning path.

Getting Started

Control or ease

Jim begins by explaining that Android provides us with two broad approaches to capturing photos and videos.

There’s the full control approach where our app directly accesses the camera, and is responsible for things like the camera preview and the camera interaction.

There’s also the ease-of-use approach, providing us with the programmatic equivalent of point and shoot. With this approach our app has no direct role in the photo or video capture. It requires very little programming effort, but also very little control.

Capture photos with ease

Jim explains this easy way of doing photo and video capture. We delegate the responsibility to a standard photo app by using an Intent with MediaStore.ACTION_IMAGE_CAPTURE.

For in depth information on Android Intents see Android Programming with Intents.

By default, the photo image is passed directly back to our app.

Jim warns that the default mode gives us a very low resolution picture,

Demo: Capture photos with ease

We start off with a sample “CameraGettingStarted” project and take a look at using an Intent to capture a picture. We start off by defining some request codes such as PHOTO_INTENT_SIMPLE

Then we define our Intent:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, PHOTO_INTENT_SIMPLE);

We use a switch statement to handle the PHOTO_INTENT_SIMPLE case.

We see the app loads up the standard photo app with cancel and take a picture options.

Specifying photo location

Jim explains how to specify the desired photo location inside an Intent.

Demo: Specifying photo location part 1

A demonstration of the concepts explained in the previous lesson.

We see how to write helper methods getPhotoDirectory and generateTimestampPhotoFileUri.

Our picture directory is set to:

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

We also need to add some some into our activity. This uses the request code PHOTO_INTENT_WITH_FILENAME.

Demo: Forcing gallery to show the photo

Jim introduces the MediaStore and says we’ll be talking about it a lot later in this course. Here we send a broadcast and use Intent.ACTION_MEDIA_MOUNTED and our file Uri.

Demo: Specifying photo location part 2

We run up our app, choose “Photo Intent with Filename” and go through the code in the debugger.

Capture videos with ease

We can use a similar technique to delegate to a standard video app with Intent.ACTION_VIDEO_CAPTURE

Demo: Capture videos with ease

Jim copies the helper methods getPhotoDirectory and generateTimestampPhotoFileUri, and renames them getVideoDirectory and generateTimestampVideoFileUri. The code changes are minimal.

The code needed in the activity is also quite simple. When we run it up it looks similar to the photo app but with a red record button for capturing video.

Jim recommends watching his Android Programming with Intents course if you’re not already familiar with using Intents.

Directly Accessing the Camera

This module covers:

  • The pros and cons of direct camera access
  • Determining camera support
  • Accessing a camera
  • Managing a camera as a shared resource

Viewing Camera Display

This module covers:

  • Creating the camera preview
  • Managing the camera preview
  • Setting the preview orientation

Taking a Picture

This module covers:

  • Steps in taking a photo
  • Taking a photo
  • Storing a photo

Camera Control

This module covers:

  • Camera behavior
  • Controlling camera behavior
  • Photo resolution
  • Photo meta data
  • Camera zoom

Recording Video

This module covers:

  • MediaRecorder
  • MediaRecorder state overview
  • MediaRecorder setup
  • Recording the video
  • MediaRecorder cleanup
  • Managing camera orientation
  • More on profiles

Media Store

This module covers:

  • Media Store
  • Media Scanner Service
  • Scanning a file
  • Thumbnails

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s