Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK for Android - set Application ID programmatically

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.

Imagine the app can be set to point to DEV, TEST, or PROD. When pointed to DEV the FB Application ID should be "1". When pointed to TEST the FB Application ID should be "2". etc.

The problem is the UiLifecycleHelper from the Facebook SDK automatically reads the "com.facebook.sdk.ApplicationId" from the AndroidManifest.xml during the onCreate phase. There doesn't appear to be a way to set this programmatically.

Is it possible to use UiLifecycleHelper and point to a different application ID at runtime or do I have to fall back to manually managing the Session?

like image 884
Matt Accola Avatar asked Feb 25 '13 17:02

Matt Accola


1 Answers

Hello all i know above answer is right for older sdk version, but in facebook sdk 4 there is no Session class

You can simply do it by using this single line code:

FacebookSdk.setApplicationId(APP_ID);

Thanks!

like image 55
Hardy Avatar answered Oct 18 '22 20:10

Hardy