0

这是我的代码:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.sharebutton:
            shareImage();
            break;

        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}

private void shareImage() {
    Intent share = new Intent(Intent.ACTION_SEND);

     share.setType("image/*");
    String imagePath = Environment.getExternalStorageDirectory()
            + "/myImage.png";

    File imageFileToShare = new File(imagePath);

    Uri uri = Uri.fromFile(imageFileToShare);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    Bitmap bmp = BitmapFactory.decodeFile(imagePath);

    startActivity(Intent.createChooser(share, "Share"));
}

我正在尝试分享我的图像,但它没有分享。我没有错误。谁能告诉我有什么问题?

4

1 回答 1

0
String pathURL = "File Real Path"
Uri bmpUri = Uri.fromFile(new File(pathURL));
Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
    startActivity(Intent.createChooser(shareIntent, "Share Image"));
于 2016-07-08T17:48:07.947 回答