====== Получить фото с камеры или галереи ======
[[http://stackoverflow.com/questions/10165302/dialog-to-pick-image-from-gallery-or-from-camera]]
7
down vote
accepted
below code can be use for takeing oand picking photo and for selection of eiher pick photo or take photo just show a dialog with two option and upon selection use the appropriate code ...
to take picture from camera.
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, 0);//zero can be replced with any action code
to pick photo from gallery
Intent pickPhoto = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(pickPhoto , 1);//one can be replced with any action code
onactivity result code::
protected void onActivityResult(int requestCode, int resultCode,
Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch (requestCode) {
case 0:
if (resultCode == RESULT_OK) {
Uri selectedImage = imageReturnedIntent.getData();
imageview.setImageURI(selectedImage);
}
break;
case 1:
if (resultCode == RESULT_OK) {
Uri selectedImage = imageReturnedIntent.getData();
imageview.setImageURI(selectedImage);
}
break;
}
}
И необходимые права в файле манифеста