The above answer given by Raja is perfect.
that’s what I did and worked great ... it used to be difficult for me to figure out what to do exactly ...
so this is what i did ... hope it can help others
// Prefer single sign-on, where available. // if (activityCode >= 0) { // singleSignOnStarted = startSingleSignOn(activity, mAppId, // permissions, activityCode); // } // Otherwise fall back to traditional dialog.
source share