Skip to content
An approach of how a third party Android application can take images using the native Camera application.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gen/com/cleverua/android
res
src/com/cleverua/android
.classpath
.gitignore
.project
AndroidManifest.xml
README.rdoc
default.properties

README.rdoc

DESCRIPTION

This sample Android application demonstrates an approach for Camera usage.

USAGE

Add camera permission to your AndroidManifest.xml file

<uses-permission android:name="android.permission.CAMERA"/>

Start camera activity in the next way:

private static final int PICK_PICTURE_CAMERA_REQUEST = 1;

...

Intent i = new Intent(this, CameraActivity.class);
startActivityForResult(i, PICK_PICTURE_CAMERA_REQUEST);

You can touch the screen or press the trackboll button to get an image from camera.

To get the camera result image Uri use onActivityResult(int requestCode, int resultCode, Intent data) method:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == PICK_PICTURE_CAMERA_REQUEST) {
          Uri imageUri = null;
          if (resultCode == RESULT_OK) {
              imageUri = data.getData();
          } else {
              showAlertDialog("Android Camera Demo", "No image taken!");
          }
          setImageTaken(imageUri);
      }
  }

If an Exception occured in the camera activity the resultCode will be RESULT_CANCELED and no data attached.

EXAMPLES

To see an example please launch the Android Camera Demo application in Android device emulator.

You can’t perform that action at this time.