Android 在eclipse中通过Intent在facebook上共享图像

Android 在eclipse中通过Intent在facebook上共享图像,android,facebook,Android,Facebook,我正在使用以下代码将图像共享到facebook,但它不起作用 Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/png"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/img1.png"));

我正在使用以下代码将图像共享到facebook,但它不起作用

                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("image/png");
                share.putExtra(Intent.EXTRA_STREAM,
                Uri.parse("/sdcard/img1.png"));
                startActivity(Intent.createChooser(share, "Share Image"));
第一,为了可读性和感官上的原因,它应该按这种顺序排列

                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("image/png");
                share.putExtra(Intent.EXTRA_STREAM,
                Uri.parse("/sdcard/img1.png"));
                startActivity(Intent.createChooser(share, "Share Image"));
  • 您需要说明错误是什么

  •                 Intent share = new Intent(Intent.ACTION_SEND);
                    share.setType("image/png");
                    share.putExtra(Intent.EXTRA_STREAM,
                    Uri.parse("/sdcard/img1.png"));
                    startActivity(Intent.createChooser(share, "Share Image"));
    
  • 永远不要硬编码图像“/sdcard/img1.png”的路径,而是使用getExternalStorageDirectory()

  •                 Intent share = new Intent(Intent.ACTION_SEND);
                    share.setType("image/png");
                    share.putExtra(Intent.EXTRA_STREAM,
                    Uri.parse("/sdcard/img1.png"));
                    startActivity(Intent.createChooser(share, "Share Image"));