Java code
Protected void onActivityResult (int requestCode, int resultCode, Intent data ){
If (resultCode = RESULT_ OK ){
// Take a photo or select an image
If (requestCode = RESULT_CAPTURE_IMAGE | requestCode = RESULT_CHOOSE_IMAGE ){
Try {
Uri uri = data. getData ();
String [] proj = {MediaStore. Images. Media. DATA };
Cursor actualimagecursor = managedQuery (uri, proj, null );
Int actual_image_column_index = actualimagecursor. getColumnIndexOrThrow (MediaStore. Images. Media. DATA );
Actualimagecursor. moveToFirst ();
String img_path = actualimagecursor. getString (actual_image_column_index );
System. out. println ("image path:" + img_path );
//
// ContentResolver resolver = getContentResolver ();
// Uri uri = data. getData ();
// System. out. println ("select image path:" + uri );
// Bitmap img = MediaStore. Images. Media. getBitmap (resolver, uri );
/// Bitmap bitmap = BitmapFactory. decodeStream (resolver. openInputStream (uri ));
/// Bitmap img = (Bitmap) data. getExtras (). get ("data"); // obtain the thumbnail
// Try {// compress the image
// File file = new File (tempPath );
// FileOutputStream outputStream = null;
// OutputStream = new FileOutputStream (file );
//
// If (img. getWidth ()> 800 | img. getHeight ()> 600 ){
// Img = Bitmap. createScaledBitmap (img, 800,600, false );
//}
// Img. compress (Bitmap. CompressFormat. JPEG, 90, outputStream );
// OutputStream. flush ();
// OutputStream. close ();
//
// SendFile (file, uri. toString (); // send an image
//// SendFile (tempPath); // send an image
//
//} Catch (IOException e ){
// E. printStackTrace ();
//}
//
// Img = null;
// System. gc ();
} Catch (OutOfMemoryError e ){
MyMethods. showMsg ("An error occurred while obtaining the image. Please operate again", this );
E. printStackTrace ();
} Catch (Exception e ){
E. printStackTrace ();
}
}
}
}
Author: "blog of pig"