I have a native Android app that needs to connect to a different Facebook app (different Application ID) based on an app setting that can be changed at runtime.
Ima
I think there is a simpler way to do this, just call the static method setApplicationId com.facebook.Settings.setApplicationId(facebookID);
And you're good to go. No need to create a session manually with the Builder and set it as the active session!
Details of the Flaw:
The facebookID you set in the settings class will be used by getMetadataApplicationId method of com.facebook.internal.Utility
public static String getMetadataApplicationId(Context context) {
Validate.notNull(context, "context");
Settings.loadDefaultsFromMetadata(context);
return Settings.getApplicationId();
}
Which in turn will be used by all the calls to create a Session:
Session(Context context, String applicationId, TokenCachingStrategy tokenCachingStrategy,
boolean loadTokenFromCache) {
// if the application ID passed in is null, try to get it from the
// meta-data in the manifest.
if ((context != null) && (applicationId == null)) {
applicationId = Utility.getMetadataApplicationId(context);
}
Validate.notNull(applicationId, "applicationId");
.
.
.
}
Cheers.