1

i want to share image on whats-app and we-chat....and so on......... i have image's on gridview....to each image click must will be open shareing option.. but m tired this make code.....plz help me.....and any idea..... and my code below.

grid_view.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View paramView, int position, long id) {
        String path=String.valueOf(position);
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);

        Uri screenshotUri = Uri.parse(path);
        sharingIntent.setType("image/*");
        if (sharingIntent !=null) {
            sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
            sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource:///drawable/" +path + ".jpg"));
            sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(Intent.createChooser(sharingIntent, "Share image using"));    
        }
        else {
            Toast.makeText(getApplication(), "Plase try agian", 2000).show();
        }

    }
});    
Morteza Soleimani
  • 2,652
  • 3
  • 25
  • 44
user2276924
  • 11
  • 2
  • 4
  • Now what was the problem?? sharing options not open?? sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); sharingIntent.putExtra(Intent.EXTRA_STREAM, sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); I think , these two lines not required. – Lokesh Mar 18 '14 at 11:27
  • Check this link: http://stackoverflow.com/questions/7661875/how-to-use-share-image-using-sharing-intent-to-share-images-in-android – Lokesh Mar 18 '14 at 11:30
  • please post your adapter code – user3355820 Mar 18 '14 at 11:33

1 Answers1

0

try this code will support share the image with multiple options

Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file)); // Add image path
startActivity(Intent.createChooser(share, "Share image using"));
Morteza Soleimani
  • 2,652
  • 3
  • 25
  • 44
user3355820
  • 272
  • 1
  • 8