CameraExample  0.1
 All Classes Namespaces Files Functions Variables Pages
edu.clemson.cameraexample.MainActivity Class Reference

This Application uses the Camera API to select and take pictures and video. More...

Inheritance diagram for edu.clemson.cameraexample.MainActivity:

Public Member Functions

boolean onCreateOptionsMenu (Menu menu)
 Inflate the menu; this adds items to the action bar if it is present. More...
 
boolean onOptionsItemSelected (MenuItem item)
 Handles menu item selection. More...
 

Protected Member Functions

void onCreate (Bundle savedInstanceState)
 Method called when activity is created. Sets the content view to activity_main or activity_main_landscape, depending on orientation. More...
 
void dispatchSelectImageIntent ()
 Start the intent to select an image. More...
 
void dispatchSelectVideoIntent ()
 Start the intent to select an video. More...
 
void dispatchTakePictureIntent ()
 Start the intent take a picture with the camera. More...
 
File createImageFile () throws IOException
 Create a .jpg file to hold the image. More...
 
void dispatchTakeVideoIntent (int videoQuality)
 Start the intent take a video with the camera. More...
 
File createVideoFile (int videoQuality) throws IOException
 Create a .jpg file to hold the image. More...
 
void onSaveInstanceState (Bundle outState)
 Here we store the file url as it will be null after returning from camera app. More...
 
void onRestoreInstanceState (Bundle savedInstanceState)
 Here we restore the fileUri again. More...
 
void rotateAndSetImage (ImageView imageView, String path)
 Rotate the image to always be in portrait mode. Workaround needed for some Androids. More...
 
void onActivityResult (int requestCode, int resultCode, Intent data)
 Work with results of activity. More...
 

Private Attributes

Uri mediaUri
 This contains the uri of the newly taken picture or video. More...
 
VideoView videoView
 The associated VideoView for this activity. More...
 
ImageView imageView
 The associated imageView for this activity. More...
 
TextView videoTextView
 Information for the videoView. More...
 
TextView imageTextView
 

Static Private Attributes

static final int IMAGE_REQUEST_CODE = 1
 
static final int REQUEST_IMAGE_CAPTURE = 2
 
static final int REQUEST_VIDEO_CAPTURE = 3
 
static final int VIDEO_REQUEST_CODE = 4
 
static final int LOW_QUALITY_VIDEO = 0
 
static final int HIGH_QUALITY_VIDEO = 1
 
static final String IMAGE_DIRECTORY ="images"
 
static final String VIDEO_DIRECTORY ="videos"
 

Detailed Description

This Application uses the Camera API to select and take pictures and video.

Author
James Burton (jburto2 AT clemson DOT edu)

Definition at line 35 of file MainActivity.java.

Member Function Documentation

protected file edu.clemson.cameraexample.MainActivity.createImageFile ( ) throws IOException
protected

Create a .jpg file to hold the image.

Returns
New image File.

Definition at line 289 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.IMAGE_DIRECTORY.

Referenced by edu.clemson.cameraexample.MainActivity.dispatchTakePictureIntent().

protected file edu.clemson.cameraexample.MainActivity.createVideoFile ( int  videoQuality) throws IOException
protected

Create a .jpg file to hold the image.

Parameters
videoQualityHigh or low quality video
Returns
New Video File.

Definition at line 364 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.LOW_QUALITY_VIDEO, and edu.clemson.cameraexample.MainActivity.VIDEO_DIRECTORY.

Referenced by edu.clemson.cameraexample.MainActivity.dispatchTakeVideoIntent().

protected void edu.clemson.cameraexample.MainActivity.dispatchSelectImageIntent ( )
protected

Start the intent to select an image.

See more about working with an image picker from http://www.vogella.com/tutorials/AndroidCamera/article.html

Definition at line 203 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.IMAGE_REQUEST_CODE.

Referenced by edu.clemson.cameraexample.MainActivity.onOptionsItemSelected().

protected void edu.clemson.cameraexample.MainActivity.dispatchSelectVideoIntent ( )
protected

Start the intent to select an video.

See more about working with an image picker from http://www.vogella.com/tutorials/AndroidCamera/article.html

Definition at line 224 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.VIDEO_REQUEST_CODE.

Referenced by edu.clemson.cameraexample.MainActivity.onOptionsItemSelected().

protected void edu.clemson.cameraexample.MainActivity.dispatchTakePictureIntent ( )
protected

Start the intent take a picture with the camera.

Started with this http://developer.android.com/training/camera/photobasics.html But ran into this problem http://stackoverflow.com/questions/13912095/java-lang-nullpointerexception-on-bundle-extras-data-getextras If a new picture or video is saved to an external file and not to the gallery, then the data returned from the intent will be null. Therefore, the uri information must be stored in an instance variable.

Definition at line 246 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.createImageFile(), edu.clemson.cameraexample.MainActivity.mediaUri, and edu.clemson.cameraexample.MainActivity.REQUEST_IMAGE_CAPTURE.

Referenced by edu.clemson.cameraexample.MainActivity.onOptionsItemSelected().

protected void edu.clemson.cameraexample.MainActivity.dispatchTakeVideoIntent ( int  videoQuality)
protected

Start the intent take a video with the camera.

Parameters
videoQualityLOW_QUALITY_VIDEO or HIGH_QUALITY_VIDEO

Started with this http://developer.android.com/training/camera/photobasics.html But ran into this problem http://stackoverflow.com/questions/13912095/java-lang-nullpointerexception-on-bundle-extras-data-getextras If a new picture or video is saved to an external file and not to the gallery, then the data returned from the intent will be null. Therefore, the uri information must be stored in an instance variable.

Definition at line 313 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.createVideoFile(), edu.clemson.cameraexample.MainActivity.mediaUri, and edu.clemson.cameraexample.MainActivity.REQUEST_VIDEO_CAPTURE.

Referenced by edu.clemson.cameraexample.MainActivity.onOptionsItemSelected().

edu.clemson.cameraexample.MainActivity.onActivityResult ( int  requestCode,
int  resultCode,
Intent  data 
)
protected

Work with results of activity.

Parameters
requestCodeRequest Code sent to activity
resultCodeResult Code returned to activity
dataData associated with the intent that called this activity.

Big catchall for all the result of all the activities that can be launched by this activity. Action is determined by requestCode and resultCode.

Creating thumbnails for video: http://android-er.blogspot.com/2011/05/create-thumbnail-for-video-using.html

Fixed null pointer exceptions from - http://www.androidhive.info/2013/09/android-working-with-camera-api/

Fixed null pointer exceptions from - http://www.androidhive.info/2013/09/android-working-with-camera-api/

Creating thumbnails for video: http://android-er.blogspot.com/2011/05/create-thumbnail-for-video-using.html

Definition at line 473 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.IMAGE_REQUEST_CODE, edu.clemson.cameraexample.MainActivity.mediaUri, edu.clemson.cameraexample.MainActivity.REQUEST_IMAGE_CAPTURE, edu.clemson.cameraexample.MainActivity.REQUEST_VIDEO_CAPTURE, and edu.clemson.cameraexample.MainActivity.VIDEO_REQUEST_CODE.

protected void edu.clemson.cameraexample.MainActivity.onCreate ( Bundle  savedInstanceState)
protected
public boolean edu.clemson.cameraexample.MainActivity.onCreateOptionsMenu ( Menu  menu)

Inflate the menu; this adds items to the action bar if it is present.

Parameters
menuMenu to be created.
Returns
true

Definition at line 146 of file MainActivity.java.

protected void edu.clemson.cameraexample.MainActivity.onRestoreInstanceState ( Bundle  savedInstanceState)
protected

Here we restore the fileUri again.

See #11 at: http://www.androidhive.info/2013/09/android-working-with-camera-api/

Definition at line 415 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.mediaUri.

protected void edu.clemson.cameraexample.MainActivity.onSaveInstanceState ( Bundle  outState)
protected

Here we store the file url as it will be null after returning from camera app.

See #11 at: http://www.androidhive.info/2013/09/android-working-with-camera-api/

Definition at line 401 of file MainActivity.java.

References edu.clemson.cameraexample.MainActivity.mediaUri.

protected void edu.clemson.cameraexample.MainActivity.rotateAndSetImage ( ImageView  imageView,
String  path 
)
protected

Rotate the image to always be in portrait mode. Workaround needed for some Androids.

Rotating images from http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/3/

Rotating images from http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/3/

Definition at line 428 of file MainActivity.java.

Member Data Documentation

final int edu.clemson.cameraexample.MainActivity.HIGH_QUALITY_VIDEO = 1
staticprivate
final String edu.clemson.cameraexample.MainActivity.IMAGE_DIRECTORY ="images"
staticprivate
final int edu.clemson.cameraexample.MainActivity.IMAGE_REQUEST_CODE = 1
staticprivate
TextView edu.clemson.cameraexample.MainActivity.imageTextView
private

Definition at line 88 of file MainActivity.java.

Referenced by edu.clemson.cameraexample.MainActivity.onCreate().

private ImageView edu.clemson.cameraexample.MainActivity.imageView
private

The associated imageView for this activity.

Definition at line 74 of file MainActivity.java.

Referenced by edu.clemson.cameraexample.MainActivity.onCreate().

final int edu.clemson.cameraexample.MainActivity.LOW_QUALITY_VIDEO = 0
staticprivate
private Uri edu.clemson.cameraexample.MainActivity.mediaUri
private

This contains the uri of the newly taken picture or video.

I started with the tutorial at http://developer.android.com/training/camera/photobasics.html, but ran into this problem http://stackoverflow.com/questions/13912095/java-lang-nullpointerexception-on-bundle-extras-data-getextras If a new picture or video is saved to an external file and not to the gallery, then the data returned from the intent will be null. Therefore, the uri information must be stored in an instance variable.

Definition at line 62 of file MainActivity.java.

Referenced by edu.clemson.cameraexample.MainActivity.dispatchTakePictureIntent(), edu.clemson.cameraexample.MainActivity.dispatchTakeVideoIntent(), edu.clemson.cameraexample.MainActivity.onActivityResult(), edu.clemson.cameraexample.MainActivity.onRestoreInstanceState(), and edu.clemson.cameraexample.MainActivity.onSaveInstanceState().

final int edu.clemson.cameraexample.MainActivity.REQUEST_IMAGE_CAPTURE = 2
staticprivate
final int edu.clemson.cameraexample.MainActivity.REQUEST_VIDEO_CAPTURE = 3
staticprivate
final String edu.clemson.cameraexample.MainActivity.VIDEO_DIRECTORY ="videos"
staticprivate
final int edu.clemson.cameraexample.MainActivity.VIDEO_REQUEST_CODE = 4
staticprivate
private TextView edu.clemson.cameraexample.MainActivity.videoTextView
private

Information for the videoView.

Definition at line 81 of file MainActivity.java.

Referenced by edu.clemson.cameraexample.MainActivity.onCreate().

private VideoView edu.clemson.cameraexample.MainActivity.videoView
private

The associated VideoView for this activity.

Definition at line 68 of file MainActivity.java.

Referenced by edu.clemson.cameraexample.MainActivity.onCreate().


The documentation for this class was generated from the following file: