Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
Log.e("RegisterACtivity", "OpenGallery");
startActivityForResult(i, 1);
I am using this code and its working fine for me. but it is opening up the gallery if there will be images in your download folder it will show you definitely.
and below is code to get the result and set that path on your image view. i am setting this first on image view . you can upload your image by converting your path into byte array
protected void onActivityResult(int requestCode, int resultCode,
Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
Log.e("RegisterActivity", "" + requestCode + "...." + resultCode);
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
Uri _image = imageReturnedIntent.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(_image,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imagePath = cursor.getString(columnIndex);
cursor.close();
Log.e("FilePath", imagePath);
image.setImageBitmap(BitmapFactory.decodeFile(imagePath));
/*
* Bitmap bitmap = BitmapFactory.decodeFile(imagePath); Bitmap
* resized = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
* Bitmap conv_bm = getRoundedRectBitmap(resized, 200);
* image.setImageBitmap(conv_bm);
*/
}
}
}