-1

I am implementing google+ and facebook integration in my android app. After login through facebook or google+, next activity will come. In that activity how can i manage both facebook and google+ logout using my logout button?

public void googlePlusLogout() {
if (LoginActivity.mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(LoginActivity.mGoogleApiClient);
LoginActivity.mGoogleApiClient.disconnect();
   }
} // Update - coed formatting

public void facebookLogout(){
LoginManager.getInstance().logOut();
}

facebooklogout method is working fine. But if i call google+ logout method it is not working.

Rakesh
  • 756
  • 1
  • 9
  • 19
MinnuKaAnae
  • 1,646
  • 3
  • 23
  • 35

2 Answers2

1

call this function for Google Plus Logout

 private void googlePlusLogout() {
        if (mGoogleApiClient != null)
            if (mGoogleApiClient.isConnected()) {
                Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
                mGoogleApiClient.disconnect();
                mGoogleApiClient.connect();
            }
    }
Bajirao Shinde
  • 1,356
  • 1
  • 18
  • 26
  • getting mGoogleApiClient is null – MinnuKaAnae Feb 24 '16 at 09:39
  • In loginactivity i have kept public static for GoogleApiClient mGoogleApiClient; by using class name i am getting mGoogleApiClient – MinnuKaAnae Feb 24 '16 at 09:44
  • If i remove static how can i access it in another activity? – MinnuKaAnae Feb 24 '16 at 09:47
  • i am using this link http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/ – MinnuKaAnae Feb 24 '16 at 10:01
  • Thank you so much for your help. Now i am getting logout. I have again added this code in my another activity mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN).build(); – MinnuKaAnae Feb 24 '16 at 10:06
  • hi brother, one more help in fb integration. how can i get emailid. List permissions = new ArrayList(); permissions.add(“email”); Add all the permissions you need and then loginButton.setReadPermissions(permissions); i am not getting if i use that – MinnuKaAnae Feb 24 '16 at 11:20
  • Brother dont misunderstand me. I am having only 4 reputation – MinnuKaAnae Feb 24 '16 at 11:24
  • bro i have done that only. but it is saying thanks for ur feedback. once you have 15 reputation your vote will be changed ..... – MinnuKaAnae Feb 24 '16 at 11:30
  • System.out.println(profile.getFirstName()); System.out.println(profile.getLastName()); System.out.println(profile.getId()); System.out.println(profile.getName()); getting these informations but not emailid – MinnuKaAnae Feb 24 '16 at 11:31
  • facebook brother. Getting email id ..Now. – MinnuKaAnae Feb 24 '16 at 12:29
  • Hi bro, i have one doubt regarding facebook key hash generation. I have generated hashkey and kept in facebook developer console. Every thing is working fine. But do i need to regenerate hashkey for app release? – MinnuKaAnae Feb 26 '16 at 06:50
  • Previously i have generated using one class Application.java found in google search. Now How can i do release key hash? – MinnuKaAnae Feb 26 '16 at 07:01
  • Means same Application.java will provide the another key after apk is signed. Am i correct bro. – MinnuKaAnae Feb 26 '16 at 07:17
  • Thank you so much for your quick response bro. I'll do like that, i'll tell u – MinnuKaAnae Feb 26 '16 at 07:35
  • Bro, i didnt get any hashkey while signing apk, After sign the apk, executed the app. getting same hashkey – MinnuKaAnae Feb 26 '16 at 08:25
  • follow this link for answer http://stackoverflow.com/questions/17423870/is-there-any-way-to-get-key-hash-from-signed-apk – Bajirao Shinde Feb 26 '16 at 08:30
  • Bro..Now i have reputation >15.I have accepted your answer. – MinnuKaAnae Feb 26 '16 at 12:37
  • Having one problem related to imageview scaling – MinnuKaAnae Apr 12 '16 at 12:13
  • i have bitmap size width 440 and height 660. and also have xy coordinates(client location), all are getting from server. now my problem if i change the size of imageview then xy coordinates are not on same position. How to solve this issue? – MinnuKaAnae Apr 12 '16 at 12:19
  • bro. My question is i am getting one image from server, image width is 440 and height is 660. And also i am getting xy coordinates from server nothing but client location. working fine in phones. If i run that app in tabs, working fine, but my requirement is that imageview have to fill the full screen in that case those xy coordinates are not on same position. So how to calculate those imageview size and xy coordinates for tablets? – MinnuKaAnae Apr 12 '16 at 12:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/108936/discussion-between-user5594218-and-bajirao-shinde). – MinnuKaAnae Apr 12 '16 at 12:39
  • Hi bro, I am getting one issue. i.e., i have to show 2 scenarios on bitmap. one is user location, second is direction to particular location. I am getting individually two scenarios. But if i combine two scenarios i.e, if i show direction to path user location is path point is overriding. How to solve this issue. Please help me, any one scenario is working at a time – MinnuKaAnae Apr 14 '16 at 10:31
1

try this :

 public void  signoutGoogle(){

            Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                   new ResultCallback<Status>() {
                       @Override
                       public void onResult(Status status) {

                           Intent intent = new Intent(HomeActivity.this, HomeActivity.class);
                           startActivity(intent);


                       }
                   });
       }
Parsania Hardik
  • 4,593
  • 1
  • 33
  • 33