Share multiple photos in facebook in android

Step 1 : Do all actions mentioned in link for fb login https://developers.facebook.com/docs/facebook-login/android. (Ex: sha1 key,release key,etc..,)

Step 2 : create SharePhotoGraph(Activity) like below attached find it.

Step 5 : Run execute and watch the output in layout. Over.

Step 6 : Comment this tutorial below or write what you want.

Step 7: useful code for facebook integration.

Step2 :SharingPhotoGraph

public class SharingPhotoGraph extends AppCompatActivity {

private CallbackManager callbackManager;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

FacebookSdk.sdkInitialize(getApplicationContext());

callbackManager = CallbackManager.Factory.create();

setContentView(R.layout.activity_sharing_photo_graph);

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.avaika_gor);

SharePhoto photo = new SharePhoto.Builder()

.setBitmap(bitmap)

.setUserGenerated(true)

.setCaption("avika photos")

.build();

bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.avika_gor2);

SharePhoto photo2 = new SharePhoto.Builder()

.setBitmap(bitmap)

.setCaption("avika photos")

.build();

bitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);

SharePhoto photo3 = new SharePhoto.Builder()

.setBitmap(bitmap)

.setCaption("avika photos")

.build();

SharePhotoContent photoContent = new SharePhotoContent.Builder()

.addPhoto(photo)

// .addPhoto(photo2)

// .addPhoto(photo3)

.build();

photoContent.describeContents();

ShareContent shareContent = new ShareMediaContent.Builder()

.addMedium(photo)

.addMedium(photo2)

.addMedium(photo3)

.build();

ShareDialog shareDialog = new ShareDialog(SharingPhotoGraph.this);

if (ShareDialog.canShow(ShareLinkContent.class)) {

shareDialog.show(shareContent);

}

}

@Override

protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {

super.onActivityResult(requestCode, resultCode, data);

callbackManager.onActivityResult(requestCode, resultCode, data);

}

}

output:

share multiple images

useful code :

mainfest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="mycompany.com.facebookintegration">

<uses-permission android:name="android.permission.INTERNET"/>

<application

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:supportsRtl="true"

android:theme="@style/AppTheme">

<meta-data android:name="com.facebook.sdk.ApplicationId"

android:value="@string/facebook_app_id"/>

<activity android:name="com.facebook.FacebookActivity"

android:configChanges=

"keyboard|keyboardHidden|screenLayout|screenSize|orientation"

android:label="@string/app_name" />

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

</manifest>

build.gradle(Module app):

apply plugin: 'com.android.application'

android {

compileSdkVersion 24

buildToolsVersion "24.0.0"

defaultConfig {

applicationId "mycompany.com.facebookintegration"

minSdkVersion 15

targetSdkVersion 24

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

repositories {

mavenCentral()

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:24.0.0'

compile 'com.facebook.android:facebook-android-sdk:4.17.0'

}

FacebookIntegrationApplication.java

public class FacebookIntegrationApplication extends Application {

@Override

public void onCreate() {

super.onCreate();

FacebookSdk.sdkInitialize(getApplicationContext());

AppEventsLogger.activateApp(this);

}

}

strings.xml

<resources>

<string name="app_name">FacebookIntegration</string>

<string name="facebook_app_id">354644***912746</string>

</resources>

Get facebook profile using Graph API:

the following code taken from rajesh from http://stackoverflow.com/questions/19855072/android-get-facebook-profile-picture

try {                         JSONObject data = response.getJSONObject();                         if (data.has("picture")) {                             String profilePicUrl = data.getJSONObject("picture").getJSONObject("data").getString("url");                             Bitmap profilePic = BitmapFactory.decodeStream(profilePicUrl.openConnection().getInputStream());                             // set profilePic bitmap to imageview                         }                     } catch (Exception e) {                         e.printStackTrace();                     }

source : This tutorials uses Facebook developers site.