android studio how to get image from galery or camera code example
Example: 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;
}
}