Facebook Share
- Optional. Players can share content with facebook in the game.
Image
Method
java
public static void gamedreamerFacebookShare(Context context, GDShareFacebookContent content,GamedreamerFacebookShareListener gamedreamerFacebookShareListener)Parameters
| Parameter | Description |
|---|---|
| context | Context object. |
| content | GDShareFacebookContent object, contains one attribute: linkUrl (jump to address, required). This attributes can be set via this class's setter method. |
| gamedreamerFacebookShareListener | Facebook share listener |
Callback Description
GamedreamerFacebookShareListener.onFacebookShare(ing code) callback method description:
- This method returns a code, the meaning of different code as shown in the table below:
| Parameter | Description |
|---|---|
| GamedreamerFacebookShareListener.SUCCESS | Share success |
| GamedreamerFacebookShareListener.CANCEL | User cancels sharing |
| GamedreamerFacebookShareListener.ERROR | Sharing failed |
Example Code
java
GDShareFacebookContent content=new GDShareFacebookContent();
content.setLinkUrl("http://www.baidu.com");
GDSDK.gamedreamerFacebookShare(this, content, new GamedreamerFacebookShareListener(){
@Override
public void onFacebookShare(int code) {
//Share success
if(code == GamedreamerFacebookShareListener.SUCCESS){
Toast.makeText(GameActivity.this, "Share success", Toast.LENGTH_LONG).show();
}else{
//Sharing failed
Toast.makeText(GameActivity.this, "Sharing failed", Toast.LENGTH_LONG).show();
}
}
});