The built-in camera program defines the following intent filter in manifest
XML Code
- <Intent-filter>
- <Action Android: Name = "android. Media. Action. image_capture"/>
- <Category Android: Name = "android. Intent. Category. Default"/>
- </Intent-filter>
<Intent-filter> <action Android: Name = "android. media. action. image_capture "/> <category Android: Name =" android. intent. category. default "/> </intent-filter>
So you only need to start it with the corresponding intent.
The following Android. provider. mediastore. action_image_capture = "android. Media. Action. image_capture ";
Java code
- Public class cameraintent extends activity {
- Final Static int camera_result = 0;
- Imageview mimagevview;
- @ Override
- Protected void oncreate (bundle savedinstancestate ){
- Super. oncreate (savedinstancestate );
- Setcontentview (R. layout. Contents );
- Intent I = new intent (Android. provider. mediastore. action_image_capture );
- Startactivityforresult (I, camera_result );
- }
- @ Override
- Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
- Super. onactivityresult (requestcode, resultcode, data );
- If (resultcode = result_ OK ){
- // Get extras from the intent
- Bundle extra = data. getextras ();
- // Get the returned image from the extras
- Bitmap B = (Bitmap) Extra. Get ("data ");
- Mimagevview = (imageview) findviewbyid (R. Id. returnedimageview );
- Mimagevview. setimagebitmap (B );
- }
- }
- }