Case R. Id. openphoto:
Intent intent = new intent ();
/* Enable pictures image type to set to image */
Intent. settype ("image /*");
/* Use the intent. action_get_content action */
Intent. setaction (intent. action_get_content );
/* Return to the current screen after obtaining the photo */
Startactivityforresult (intent, 1 );
Request_camera = 0;
Break;
Case R. Id. Camera:
Intent getimagebycamera = new intent (
"Android. Media. Action. image_capture ");
Startactivityforresult (getimagebycamera, request_camera );
Request_camera = 1;
Break;
Default:
Break;
}
}
@ Override
Public Boolean onkeydown (INT keycode, keyevent event ){
// Todo auto-generated method stub
If (keycode = keyevent. keycode_back ){
Startactivity (new intent (imagepageactivity. This, ordermsgactivity. Class ));
Imagepageactivity. This. Finish ();
}
Return super. onkeydown (keycode, event );
}
@ Override
Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
If (request_camera = 0 ){
Uri uri = data. getdata ();
// Log. E ("Uri", Uri. tostring ());
Contentresolver Cr = This. getcontentresolver ();
Try {
Bitmap bitmap = bitmapfactory. decodestream (Cr. openinputstream (URI ));
/* Set bitmap to imageview */
Imageview. setimagebitmap (Bitmap );
} Catch (filenotfoundexception e ){
// Log. E ("exception", E. getmessage (), e );
}
} Else if (request_camera = 1 ){
Bitmap mybitmap = NULL;
Try
{
Super. onactivityresult (requestcode, resultcode, data );
Bundle extras = data. getextras ();
Mybitmap = (Bitmap) extras. Get ("data ");
Bytearrayoutputstream baos = new bytearrayoutputstream ();
Mybitmap. Compress (bitmap. compressformat. JPEG, 100, baos );
Byte [] mcontent = baos. tobytearray ();
} Catch (exception E)
{
E. printstacktrace ();
}
// Bind the obtained image to the control for display
Imageview. setimagebitmap (mybitmap); // convert the photo into a rounded corner and display it in the preview control.
}
Super. onactivityresult (requestcode, resultcode, data );