我想在whats-app和我们聊天上分享图片....等等.........
我在gridview上有图像....单击每个图像,必须将其打开为共享选项。
但是我很讨厌这个make代码..... plz帮助我.....以及任何想法.....
和下面的代码

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();
        }

    }
});

最佳答案

这是共享意图的代码。

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));

Intent sendIntent = new Intent(Intent.ACTION_SEND);

sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(mScreenshotPath+"/"+curentDateandTime+".png")));
startActivityForResult(sendIntent, 0);

09-12 17:48