Skip to content

Facebook Image Sharing ​

  • Optional. Players can share images from the game to Facebook.

Illustration ​

Facebook image sharing illustration

Modify File ​

Modify the AndroidManifest.xml file and add the queries tag section (new: 20211228)

java
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.app">
    <uses-permission ....../>
	...
    <queries>
              <provider android:authorities="com.facebook.katana.provider.PlatformProvider"
            android:exported="false" />
    </queries>
    ...
	<application ....../>
</manifest>

Function ​

java
public static void gamedreamerFacebookShareImage(Context context,Bitmap bitmap, GamedreamerFacebookShareListener listener)

Parameters ​

ParameterDescription
contextContext object
bitmapBitmap image
listenerFacebook image sharing listener.

Callback Description ​

GamedreamerFacebookShareListener.onFacebookShare(int code) callback method description

  • This method returns a code. Different codes indicate the following results:
ParameterDescription
GamedreamerFacebookShareListener.SUCCESSShare succeeded
GamedreamerFacebookShareListener.CANCELUser canceled sharing
GamedreamerFacebookShareListener.ERRORShare failed

Example Code ​

java
Bitmap sharedPhoto = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier("gd_logo_landscape", "drawable",getPackageName()));
GDSDK.gamedreamerFacebookShareImage(this,sharedPhoto, new GamedreamerFacebookShareListener() {
	@Override
	public void onFacebookShare(int code) {
		if(code == GamedreamerFacebookShareListener.SUCCESS){
			Toast.makeText(GameActivity.this, "Share succeeded", Toast.LENGTH_LONG).show();
		}
	}
});