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
Here what i used to set the application id programatcally
private Session.StatusCallback statusCallback = new SessionStatusCallback();
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String s=""+R.string.app_id;
Session session = new Session.Builder(getBaseContext()).setApplicationId(s).build();
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
}
}
private class SessionStatusCallback implements Session.StatusCallback {
@Override
public void call(Session session, SessionState state, Exception exception) {
// TODO Auto-generated method stub
if(session.isOpened()){
//Do your task
}
}
}