Lập trình Android Images

6 463 7
Lập trình Android Images

Đang tải... (xem toàn văn)

Thông tin tài liệu

Android Images

@2011 Mihail L. Sichitiu 1 Android Introduction Camera Many thanks to Jun Bum Lim for his help with this tutorial. @2010 Mihail L. Sichitiu 2 Goal  Create an application that launches the built-in Camera and use the results for displaying the captured image. Layout  Make a LinearLayout with  a TextView,  a Button, and  an ImageView  Create a handler for the OnClick event of the Button @2010 Mihail L. Sichitiu 3 @2010 Mihail L. Sichitiu 4 Launch Camera Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);           Creating an Intent, as follows, within your button click handler: startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);    Launch camera activity with asking result: private static final int CAMERA_PIC_REQUEST = 1;  define within your application as the request code returned by the Camera image capture Intent Handling result from Camera @2010 Mihail L. Sichitiu 5 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); } }  By adding onActivityResult() in your Activity: Enforcing Device Requirement @2010 Mihail L. Sichitiu 6 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/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 android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".AndroidCameraActivity" android:label="@string/app_name"> <intent-filter> : : Application wants a  camera It is not enforced by  Android . <manifest xmlns :android= "http://schemas .android. com/apk/res /android& quot; 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 android: icon="@drawable/icon"

Ngày đăng: 20/11/2013, 21:10

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan