in my application i want to upload the image.for that i have to get images from gallery in android device.can pl send me that code get images from android device gallery
+4
A:
Raise an Intent with Action as ACTION_GET_CONTENT
and set the type to "image/*
". This will start the photo picker Activity. When the user selects an image, you can use the onActivityResult
callback to get the results.
Something like:
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
Uri chosenImageUri = data.getData();
Bitmap mBitmap = null;
mBitmap = Media.getBitmap(this.getContentResolver(), chosenImageUri);
}
}
Samuh
2010-02-09 13:00:49
hi samuh.by using this code i am getting image from media what's my problem is i need to store that image in remote server.i am converted mBitmap into bytearray when i try to send byte array it is shwoing 5 digit code i am feeling like it is address of the byte array .can you please help out from this problemThanks in advanceAswan
Aswan
2010-04-27 08:28:20
you are probably sending the HashCode of the byte array instead of the array elements.
Samuh
2010-04-27 09:12:16
in = new FileInputStream("/sdcard/pictures/einstein3.jpg");buf = new BufferedInputStream(in,2000);System.out.println("1.................."+buf);byte[] byteArray= new byte[buf.available()];buf.read(byteArray);now i am sending "byteArray" to server that is not sending only hashcode sending .can you suggest me where i made mistake
Aswan
2010-04-28 07:16:17