Image is not displaying in the ImageView. I can select image or take a photo of a new image but the image will not show in ImageView.
public class RequestQuoteFragment extends Fragment {
ImageButton mPostImage;
ImageView imageView;
private EditText mDescription, mWidth, mLength, mHeight;
Integer REQUEST_CAMERA = 1, SELECT_FILE = 2;
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_request_quotes, container, false);
imageView = view.findViewById(R.id.image_view);
mDescription = view.findViewById(R.id.item_description);
mWidth = view.findViewById(R.id.width);
mLength = view.findViewById(R.id.length);
mHeight = view.findViewById(R.id.height);
mPostImage = view.findViewById(R.id.attach_file);
mPostImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
attachFile();
}
});
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
return view;
}
//Attach Activity to fragments
private Context mContext;
#Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
mContext = activity;
}
private void attachFile() {
final CharSequence[] items = {"Camera", "Gallery", "Cancel"};
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(mContext);
builder.setTitle("Add Image");
builder.setItems(items, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
if(items[i].equals("Camera")) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
} else if (items[i].equals("Gallery")) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent.createChooser(intent,"Select Photo"), SELECT_FILE);
} else if (items[i].equals("Cancel")) {
dialogInterface.dismiss();
}
}
});
builder.show();
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_CAMERA) {
Bundle bundle = data.getExtras();
final Bitmap bitmap = (Bitmap) bundle.get("data");
imageView.setImageBitmap(bitmap);
} else if (requestCode == SELECT_FILE) {
Uri selectImageUri = data.getData();
imageView.setImageURI(selectImageUri);
}
}
}
//reset fields
private void resetFields() {
//UniversalImageLoader.setImage("", mPostImage);
mDescription.setText("");
mWidth.setText("");
mLength.setText("");
mHeight.setText("");
}
}
Loading image using Glide is as follows:
https://github.com/codepath/android_guides/wiki/Displaying-Images-with-the-Glide-Library
This one worked for me.
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT).setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Profile Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent});
startActivityForResult(chooserIntent, AppConstants.PICK_IMAGE);
And
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK && requestCode == AppConstants.PICK_IMAGE)
{
image.setImageURI(data.getData());
}
}
Edited
Otherwise
startActivityForResult(intent.createChooser(intent,"Select Photo"), SELECT_FILE);
Change above line to
startActivityForResult(Intent.createChooser(intent,"Select Photo"), SELECT_FILE);
There a small mistake on your code, that you have to check, resultCode == Activity.RESULT_OK, instead of requestCode == Activity.RESULT_OK
Hope it will help your issue. Thanks!
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_CAMERA) {
Bundle bundle = data.getExtras();
final Bitmap bitmap = (Bitmap) bundle.get("data");
imageView.setImageBitmap(bitmap);
} else if (requestCode == SELECT_FILE) {
Uri selectImageUri = data.getData();
imageView.setImageURI(selectImageUri);
}
}
}
Related
I've been trying to pass the image from gallery or from camera to another activity but they don't work properly. If the image from the gallery will work then the image from camera won't work and vice versa. Please help me fix my code. Here are my code for the MainActivity and for the SecondActivity. Thank you!
MainActivity.java
public class MainActivity extends AppCompatActivity {
Button btnStart,btnGallery,btnAbout;
ImageView reademlogo, pianotiles,imgclouds,imgclouds2,imgsharp,imgfclef;
TextView txtread;
Typeface tf1;
private final int REQUEST_IMAGE_CAPTURE = 1;
private final int PICK_IMAGE = 1;
Uri imageUri;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
UserInterface();
}
private void UserInterface() {
btnStart = (Button)findViewById(R.id.btnStart);
btnGallery = (Button)findViewById(R.id.btnGallery);
btnAbout = (Button)findViewById(R.id.btnAbout);
reademlogo = (ImageView)findViewById(R.id.reademLogo);
pianotiles = (ImageView)findViewById(R.id.pianotiles);
imgclouds = (ImageView)findViewById(R.id.imgclouds);
imgclouds2 = (ImageView)findViewById(R.id.imgclouds2);
imgsharp = (ImageView)findViewById(R.id.imgsharp);
imgfclef = (ImageView)findViewById(R.id.imgfclef);
txtread = (TextView)findViewById(R.id.txtread);
tf1 = Typeface.createFromAsset(getAssets(),
"fonts/VeganStylPersonalUse.ttf");
txtread.setTypeface(tf1);
}
public void captureImage(View view) {
Intent iCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (iCamera.resolveActivity(getPackageManager()) != null) {
startActivityForResult(iCamera, REQUEST_IMAGE_CAPTURE);
}
}
public void galImage(View view) {
Intent iGallery = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.INTERNAL_CONTENT_URI);
iGallery.setType("image/*");
startActivityForResult(iGallery, PICK_IMAGE);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK && requestCode == REQUEST_IMAGE_CAPTURE){
Bitmap bitmap = (Bitmap)Objects.requireNonNull(data.getExtras()).get("data");
Intent intent = new Intent(MainActivity.this,Camera.class);
intent.putExtra("Bitmap",bitmap);
startActivity(intent);
}
else if(requestCode == PICK_IMAGE){
if(data != null){
imageUri = data.getData();
Intent intent = new Intent(MainActivity.this,Camera.class);
intent.putExtra("imageUri",imageUri);
startActivity(intent);
}
}
}
}
Camera.java
public class Camera extends AppCompatActivity {
Button btnCap, btnUse;
ImageView imageView3;
Uri imageUri;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
btnCap = (Button) findViewById(R.id.btnCap);
btnUse = (Button) findViewById(R.id.btnUse);
imageView3 = (ImageView) findViewById(R.id.imageView3);
if (getIntent().getExtras() != null) {
imageUri = Uri.parse(getIntent().getStringExtra("imageUri"));
imageView3.setImageURI(imageUri);
}
Intent intentCam = getIntent();
Bitmap camera_img = (Bitmap)intentCam.getParcelableExtra("Bitmap");
if(camera_img != null){
imageView3.setImageBitmap(camera_img);
}
}
}
Try this it is working fine for me.
//Use this method to select image from Gallery
private void processGalleryImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
GALLERY_REQUEST_CODE);
}
//Use this method to click image from Camera
private void processCameraImage() {
Intent cameraIntent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE);
}
//Use this method to get image from Gallery/Captured from Camera
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == CAMERA_REQUEST_CODE) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
//Starting activity (ImageViewActivity in my code) to preview image
Intent intent = new Intent(this, ImageViewActivity.class);
intent.putExtra("BitmapImage", photo);
startActivity(intent);
} else if (requestCode == GALLERY_REQUEST_CODE) {
if (data.getData() != null) {
Uri imageUri = data.getData();
//Starting activity (ImageViewActivity in my code) to preview image
Intent intent = new Intent(this, ImageViewActivity.class);
intent.putExtra("ImageUri", imageUri.toString());
startActivity(intent);
}
}
}
}
//ImageViewActivity code
private Bitmap bitmap;
private String uri;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
ButterKnife.bind(this);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
bitmap = bundle.getParcelable("BitmapImage");
uri = bundle.getString("ImageUri");
if (bitmap != null)
imageView.setImageBitmap(bitmap);
else
Glide.with(this).load(uri).into(imageView);
}
}
I am using the Glide library to load image in image view in case if i have image url.
I am trying to get image from phone gallery or capturing image from camera..I have used 'me.villani.lorenzo.android:android-cropimage:1.1.+' for croping the image..It works well for getting image from phone gallery..While Capturing the image from camera,It captured the image but it cannot able to crop..It works fine on Choose from Image from gallery..Here i included my code,please have a look,
public class Details extends AppCompatActivity {
ImageView i1,i2;
Bitmap bitmapPic;
private static int REQUEST_PICTURE = 1;
private final static int REQUEST_PERMISSION_REQ_CODE = 34;
private static int REQUEST_CAMERA = 0, SELECT_FILE = 1, REQUEST_CROP_PICTURE = 2;
private static int CROP_IMAGE_SIZE = 200;
private static int CROP_IMAGE_HIGHLIGHT_COLOR = 0x6aa746F4;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
android.support.v7.app.ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.hide();
}
i1 = (ImageView)findViewById(R.id.prof1);
i2 = (ImageView)findViewById(R.id.prof2);
i1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
selectImageOption();
}
});
}
private void selectImageOption() {
final CharSequence[] items = { "Capture Photo", "Choose from Gallery", "Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(Details.this);
builder.setTitle("Add Photo!");
builder.setItems(items, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals("Capture Photo")) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
} else if (items[item].equals("Choose from Gallery")) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("return-data", true);
startActivityForResult(intent, SELECT_FILE);
} else if (items[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
File croppedImageFile = new File(getFilesDir(), "Pic.jpg");
Uri croppedImage = Uri.fromFile(croppedImageFile);
if (requestCode == REQUEST_CROP_PICTURE && resultCode == RESULT_OK) {
bitmapPic = BitmapFactory.decodeFile(croppedImageFile.getAbsolutePath());
if (bitmapPic != null) {
i1.setImageBitmap(bitmapPic);
} else {
Toast.makeText(Details.this, "Image Error while Cropping", Toast.LENGTH_LONG).show();
}
} else if (resultCode == RESULT_OK && (requestCode == REQUEST_CAMERA || requestCode == SELECT_FILE)) {
showImageCropView(data, croppedImage);
}
}
private void showImageCropView(Intent data, Uri croppedImage) {
CropImageIntentBuilder cropImage = new CropImageIntentBuilder(CROP_IMAGE_SIZE, CROP_IMAGE_SIZE, croppedImage);
cropImage.setOutlineColor(CROP_IMAGE_HIGHLIGHT_COLOR);
cropImage.setSourceImage(data.getData());
cropImage.setCircleCrop(true);
startActivityForResult(cropImage.getIntent(this), REQUEST_CROP_PICTURE);
}
}
Captured Image from Camera does not able to crop!Please give me better Solution for this.!Thanks in Advance
Bro, check this out. May solve your problem, you can crop the image from camera / gallery. link
set
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="#style/Base.Theme.AppCompat"/> <!-- optional (needed if default theme has no action bar) -->
to your manifest
call startCropImageActivity(null); in onclick method
this is the method :
private void startCropImageActivity(Uri imageUri) {
CropImage.activity(imageUri)
.setGuidelines(CropImageView.Guidelines.ON)
.setMultiTouchEnabled(true)
.setRequestedSize(320, 320, CropImageView.RequestSizeOptions.RESIZE_INSIDE)
.setMinCropWindowSize(0,0)
.setAspectRatio(1,1)
.setCropShape(CropImageView.CropShape.OVAL)
.start(this);
}
and in onActivityResult
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
((CircleImageView) findViewById(R.id.profileImage)).setImageURI(result.getUri());
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(this, "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
}
}
}
Here I'm using CircleImageView as circle image
I don't know why my code which was just working and has suddenly stopped? I want to take a picture through my image button, and then display it in an Image View. Here`s my code that won't display in the Image View:
public class UserInterface extends AppCompatActivity {
private static final int REQUEST_IMAGE_CAPTURE= 1;
private ImageView imageView;
ImageButton cap;
Bundle extras;
Bitmap imageBitmap;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_interface);
imageView = (ImageView)this.findViewById(R.id.imageView1);
cap = (ImageButton) this.findViewById(R.id.cap);
cap.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
extras = data.getExtras();
imageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(imageBitmap);
}
}
}
Uri imageUri;
On your button click listener:
cap.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageUri = Uri.fromFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
});
On activity result:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
imageView.setImageURI(imageUri);
}
}
I am new to Android, and I have done lots of training but the image does not load from the camera. Below is my code for capturing image from camera or gallery:
public void showDiloag(){
Dialog dialog = new Dialog(getActivity());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Choose Image Source");
builder.setItems(new CharSequence[] { "Gallery", "Camera" },
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog,
int which) {
switch (which) {
case 0:
Intent intent = new Intent(
Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Intent chooser = Intent
.createChooser(
intent,
"Choose a Picture");
getAcitivity.startActivityForResult(
chooser,
ACTION_REQUEST_GALLERY);
break;
case 1:
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(
cameraIntent,
ACTION_REQUEST_CAMERA);
break;
default:
break;
}
}
});
builder.show();
dialog.dismiss();
}
And for display that photo:
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
System.out.println("OnActivityResult");
if (resultCode == getActivity().RESULT_OK) {
if (requestCode == Utils.ACTION_REQUEST_GALLERY) {
// System.out.println("select file from gallery ");
Uri selectedImageUri = data.getData();
String tempPath = JuiceAppUtility.getPath(
selectedImageUri, getActivity());
Bitmap bm = JuiceAppUtility
.decodeFileFromPath(tempPath);
imgJuice.setImageBitmap(bm);
} else if (requestCode == Utils.ACTION_REQUEST_CAMERA) {
Bitmap photo = (Bitmap) data.getExtras()
.get("data");
imgJuice.setImageBitmap(photo);
}
}
}
Also image is captured from camera and choose from gallery but it will not load in ImageView. Can anybody help me please?
Ya i found your problem
just remove below line and
getAcitivity.startActivityForResult(
chooser,
ACTION_REQUEST_GALLERY);
and write down below code
startActivityForResult(
chooser,
ACTION_REQUEST_GALLERY);
just remove getActivity
FRAGMENT SIDE
btnimage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
showPictureDialog();
}
});
private void showPictureDialog(){android.app.AlertDialog.Builder pictureDialog = new android.app.AlertDialog.Builder(getActivity());
pictureDialog.setTitle("Select Action");
String[] pictureDialogItems = {
"Select photo from gallery",
"Capture photo from camera"};
pictureDialog.setItems(pictureDialogItems,
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
// choosePhotoFromGallary();
choosePhotoFromGallary();
break;
case 1:
// takePhotoFromCamera();
takePhotoFromCamera();
break;
}
}
});
pictureDialog.show();
}
private void takePhotoFromCamera() {
Uri resultUri;
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
resultUri = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new ContentValues());
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, resultUri);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(intent, 22);
}
}
public void choosePhotoFromGallary() {
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, 11);
}
#Override
public void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == getActivity().RESULT_OK)
{
if (requestCode == 11) {
if (data != null) {
Uri contentURI = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), contentURI);
// String path = saveImage(bitmap);
// Toast.makeText(getActivity(), "Image Saved!", Toast.LENGTH_SHORT).show();
iv_froncnic.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "Failed!", Toast.LENGTH_SHORT).show();
}
}
{
Toast.makeText(getActivity(), "Data not found", Toast.LENGTH_SHORT).show();
}
}
}
}
In parent ACTIVITY
#Override
protected void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
if (resultCode==this.RESULT_OK){
super.onActivityResult(requestCode, resultCode, data);
setResult(RESULT_OK, data);
}
}
In my simple Activity I launch the selection of an image.
On the result of the selection i want to show the image.
But debugging I see that resultCode == RESULT_OK is not true.
What am i doing wrong here???
public class PictureActivity extends Activity {
private static final int SELECT_PICTURE = 1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, SELECT_PICTURE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setType("image/*");
intent.setData(data.getData());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
}
}
It is because of:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
From the documentation: http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK
"This flag can not be used when the caller is requesting a result from the activity being launched."
Use my Code :-
Uri selectedImageUri; // Global Variable
String selectedPath; // Global Variable
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView preview = findViewById(R.id.preview);
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select file to upload "), 10);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if(data.getData() != null){
selectedImageUri = data.getData();
}else{
Log.d("selectedPath1 : ","Came here its null !");
Toast.makeText(getApplicationContext(), "failed to get Image!", 500).show();
}
if (requestCode == 10)
{
selectedPath = getPath(selectedImageUri);
preview.setImageURI(selectedImageUri);
Log.d("selectedPath1 : " ,selectedPath);
}
}
}