choose picture from gallery android studio code example
Example 1: select photo from camera android
private void pickFromGallery(){
Intent intent=new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
String[] mimeTypes = {"image/jpeg", "image/png"};
intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);
startActivityForResult(intent,GALLERY_REQUEST_CODE);
}
public void onActivityResult(int requestCode,int resultCode,Intent data){
if (resultCode == Activity.RESULT_OK)
switch (requestCode){
case GALLERY_REQUEST_CODE:
Uri selectedImage = data.getData();
imageView.setImageURI(selectedImage);
break;
}
}
Example 2: android pick up photo from local device
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, TFRequestCodes.GALLERY);