Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Introduction Camera.

Similar presentations


Presentation on theme: "Android Introduction Camera."— Presentation transcript:

1 Android Introduction Camera

2 Goal Create an application that launches the built-in Camera and use the results for displaying the captured image.

3 Layout Make a LinearLayout with
a TextView, a Button, and an ImageView Create a handler for the OnClick event of the Button

4 Launch Camera Creating an Intent, as follows, within your button click handler: Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); Launch camera activity with asking result: startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);   define within your application as the request code returned by the Camera image capture Intent private static final int CAMERA_PIC_REQUEST = 1; 

5 Handling result from Camera
By adding onActivityResult() in your Activity: protected void onActivityResult(int requestCode, int resultCode, Intent data) {       if (requestCode == CAMERA_PIC_REQUEST) { // display image            Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ImageView imageTakePic = (ImageView) findViewById(R.id.imageViewPhone); imageTakePic.setImageBitmap(thumbnail);     }  

6 Enforcing Device Requirement
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="ucab.test.camera" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" /> <uses-feature android:name="android.hardware.camera"></uses-feature> <application <activity android:name=".AndroidCameraActivity" <intent-filter> : Application wants a camera It is not enforced by Android


Download ppt "Android Introduction Camera."

Similar presentations


Ads by Google