如何通过Facebook和Twitter上的Android应用程序跟踪分享和喜欢的照片数量?

时间:2016-09-08 08:31:30

标签: android facebook facebook-graph-api twitter

我制作了一个Android应用程序,帮助用户拍照并分享到Facebook和Twitter等社交媒体。如何计算通过我的应用分享的那些照片的分享和喜欢

以下是我对Facebook代码的分享。

public class shareToFb extends  AsyncTask<String,Void,Bitmap>{
    private ProgressDialog progressDialog;
    @Override
    protected Bitmap doInBackground(String... params) {
        return getBitmapFromUrl(params[0]);
    }
    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        progressDialog = new ProgressDialog(ImageOverlay.this);
        progressDialog.setMessage("Sharing to fb");
        progressDialog.setCancelable(true);
        progressDialog.show();
    }

    @Override
    protected void onPostExecute(Bitmap overlayBitmap) {
        super.onPostExecute(overlayBitmap);

        progressDialog.hide();


        bitmapProfilePicture = bitmapProfilePicture.createScaledBitmap(
                bitmapProfilePicture, overlayBitmap.getWidth(),
                overlayBitmap.getHeight(), true);
        final Bitmap bitmap = overlay(bitmapProfilePicture,
                overlayBitmap);

        String f = saveBitmap(bitmap);
         callbackManager = CallbackManager.Factory.create();
        final ShareDialog shareDialog = new ShareDialog(ImageOverlay.this);
        if (ShareDialog.canShow(ShareLinkContent.class)){
            SharePhoto photo = new SharePhoto.Builder()
                    .setBitmap(bitmap)
                    .build();


            SharePhotoContent content = new SharePhotoContent.Builder()
                    .addPhoto(photo)
                    .build();


            shareDialog.show(content);

        }

    }

}

以下是我对Twitter代码的分享:

        String f = saveBitmap(bitmap);

        TweetComposer.Builder builder = new TweetComposer.Builder(ImageOverlay.this)
                .image(Uri.fromFile(new File(f)));
        builder.show();

0 个答案:

没有答案