Share Score on Facebook android

后端 未结 6 1441
一个人的身影
一个人的身影 2020-12-06 00:08

I want to share my game score on facebook. I checked lots of links and every post people are saying that POSTING on facebook using INTENT i

6条回答
  •  悲哀的现实
    2020-12-06 00:54

    Just try the below snippet,

    call wherever you want like below

    ShareDialog shareDialog;
    FacebookSdk.sdkInitialize(mContext);
    shareDialog = new ShareDialog(mContext);
    
    shareScoreonFB("345"); // just pass your score here in string format. call this inside click listener.
    
    // GLOBAL FUNCTION TO SHARE SCORE ON FB 
    void shareScoreonFB(String score)
    {
    ShareLinkContent linkContent = new ShareLinkContent.Builder()
                        .setContentTitle("Your score is : "+score)
                        .setContentDescription("Any description that you needed")
                        .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.mobtraffiq.numbertap&hl=en")).build();
                shareDialog.show(linkContent);
    }
    

    NOTE: Make sure you initialize the Facebook SDK.

    Hope this helps you, let me know for queries.

提交回复
热议问题