Could someone please help me undeprecate this bit of code? This is the example give from Facebook (on how to connect to a FB account - https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/ ), however the marked line:
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
is deprecated. I tried to replace it with:
Request.newMeRequest( session, callback, executeAsync() );
However, the code is nested so confusingly that it messes it all up. I would appreciate any help you could give as I've been at this all day.
// start Facebook Login Session.openActiveSession(this, true, new Session.StatusCallback() { // callback when session changes state @Override public void call(Session session, SessionState state, Exception exception) { if (session.isOpened()) { // make request to the /me API Request.executeMeRequestAsync(session, new Request.GraphUserCallback() { // *DEPRECATED // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { TextView welcome = (TextView) findViewById(R.id.welcome); welcome.setText("Hello " + user.getName() + "!"); } } }); } } });
}
Regards
If you're not receiving your text message (SMS) verification codes, you may have turned off text messages from Facebook. Learn how to turn text messages (SMS) back on.
Replace your Request.executeMeRequestAsync
with:
Request.newMeRequest(session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { TextView welcome = (TextView) findViewById(R.id.welcome); welcome.setText("Hello " + user.getName() + "!"); } } }).executeAsync();
i.e. Nothing changes except you're calling a slightly different method and putting .executeAsync()
at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With