Skip to content

Repository files navigation

This sample Android application demonstrates an approach for Camera usage.

<uses-permission android:name="android.permission.CAMERA"/>
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.

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.

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

About

An approach of how a third party Android application can take images using the native Camera application.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages