如何在Facebook上分享当前的活动?

时间:2018-06-07 15:46:44

标签: android

我想通过使用fb share按钮在活动上分享Facebook上的测试时间。我已经在Google搜索了这么多报价,但却无法做到这一点。我还附加了app活动网址。在这项活动中,我想在facebook上分享祝贺和调查时间。我的问题是无法在共享时获取屏幕截图并获取通知图像上传和共享失败。有什么想法吗?

App Activity url - https://i.stack.imgur.com/D7qIv.png


// code what I have tried?

   // fb share button

 fb_share_btn.setOnClickListener (new View.OnClickListener ( ) {
            @Override
            public void onClick(View view) {
                Bitmap bitmap = takeScreenshot();
                saveBitmap(bitmap);
                shareIt();
            }
        });
    }

// logic 

 public void saveBitmap(Bitmap bitmap) {
//        imagePath = new File (Environment.getExternalStorageDirectory() + "/screenshot.png");
        ContextWrapper cw = new ContextWrapper (getApplicationContext());
        File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
        imagePath = new File(directory,"/screenshot.png");

        //Log.i ("Message","Testingabc"+imagePath);
        FileOutputStream fos;
        try {
            fos = new FileOutputStream (imagePath);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {
            Log.e("GREC", e.getMessage(), e);
        } catch (IOException e) {
            Log.e("GREC", e.getMessage(), e);
        }
    }
    private void shareIt() {
        Uri uri = Uri.fromFile(imagePath);
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("image/*");
        String shareBody = "In Tweecher, My highest score with screen shot";
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Tweecher score");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
        sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);

        startActivity(Intent.createChooser(sharingIntent, "Share via"));
    }
}

0 个答案:

没有答案