I am trying to get Facebook login for authentication in my app but this problem occurs when I enter Trying to log out it is not working, someone can help me please. Code is given below
Public category Facebook login activity tool extends OnClickListener {ImageView ivFacebook, btnLogout; Facebook FB; Public static final string MyPREFERENCES = "MyPrefs"; String APP_ID; Private shared references; @SuppressWarnings ("deprecation") @ Override Crate on Protected Zero (Bundle Saved Instantstate) {Super.New (Saved Instantstate); SetContentView (R.layout.loginscreen); SP = getPreferences (Context.MODE_PRIVATE); String access_token = sp.getString ("access_token", null); Expires long = sp.getLong ("access_expires", 0); If (access_token! = Null) {fb.setAccessToken (access_token); } If (ends! = 0) {FB.SetExtensionExpier (ends); } APP_ID = getString (R.string.facebook_app_id); FB = new Facebook (APPI); IvFacebook = (imageView) findViewById (R.id.ivFacebook); IvFacebook.setOnClickListener (this); } @SuppressWarnings ("deprecation") Private Zero update button () {/ TODO automatically generated method stub I = new intent (Facebooklogin.this, MainAct.class); StartActivity (i); } @SuppressWarnings ("deprecation") Public Zero onClick (see V) {// TODO stub automatically generated method (fb.session! = Null & amp; fb.session.isOpened ()) {try {// Fb .logout (getApplicationContext ()); UpdateButton (); } Grip (Exception E) {// TODO Auto generated blocking block e.printStackTrace (); }} Else {fb.authorize (Facebooklogin.this, new string [] {"email"}, New Dialoglister () {@Override FacebookError (FacebookError e) on the public void {// TODO auto generated method stub} @ Override Public Zero OnError (DialogError e) {// TODO Auto-generated method stub} @OverrideConplete public void (bundle value) {// TODO auto generated method stub editor editor = sp.edit (); editor.putString ("access_token", Fb .getAccessToken ();; Editor Long ("access_expires", fb.getAccessExpires ()); editor.commit (); updateButton ();} @OverrideConcal public void () {// TODO auto generated method stub} }); }} @SuppressWarnings ("deprecation") @ override protected activation results at zero (int requestcode, int result result, intent data) {/ TODO auto generated method stub super.onactivative result (requestcode, resultcode, data); Fb.authorize callback (requestcode, resultcode, data); }
I do not see any line to logout here, you session In order to clean the logout order.
if (session! = Zero) {session.closeAndClearTokenInformation (); Session = null; }
Also remove the token from the shared preferences and note that you are using an older version of Facebook API. The above methods have now been deprecated.
No comments:
Post a Comment