I want to share image from specified path in android.my code is Working but image not sharing like facebook,google drive etc..!,My Share Intent doesn’t Send image to other application!.
What’s Wrong in my code help me any one greatly appreciated!
Here’s my code:
File wallpaperDirectory = new File("/sdcard/myimage/");
// have the object build the directory structure, if needed.
wallpaperDirectory.mkdirs();
File file = new File(wallpaperDirectory, "Share.jpg");
try {
fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.toString(),5000).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(file.getAbsolutePath());
sharingIntent.setType("image/jpg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
here’s myoutput:

after click option doesn’t share image to other application!
I am find good tutorial for image sharing below link:
http://collegewires.com/android/2012/06/android-implementing-a-share-intent/
and my problem is file path is not correct add path before
file://like below code:
now my problem was solved!