Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for deprecated Facebook code for Android

I want to know the exact replacement for the below code without deprecated code. Moreover, i want to try it in new Facebook SDK 3.0.

Facebook aFacebook = new Facebook("app_id");
if( !aFacebook.isSessionValid() ) {
    aFacebook.authorize(this, new String[] { "email" }, 
                        new LoginDialogListener());
}

I tried many thing. But, couldn't get it done.

TIA

like image 315
Gugan Avatar asked Jan 19 '13 08:01

Gugan


1 Answers

Since this question has no answer, I am writing one.

In 3.0 Facebook SDK for Android, Session class is used to Login. Initially, as mentioned in the question, the authorize method was used.

The code to serve as exact replacement for the code mentioned in question:

Session session = Session.getActiveSession();
    if (session == null) {
        session = new Session(getApplicationContext());
    }
Session.setActiveSession(session);
like image 114
Karan Sharma Avatar answered Nov 15 '22 04:11

Karan Sharma