0

How to call sign out from another activity when user is logged in using google account. Like in my app there is an activity LoginActivity which contains signin() and signout() methods once this activity has finished it goes to suppose A activity then how to call signout from A activity.

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Uday Naidu
  • 532
  • 1
  • 6
  • 16
  • Can you please share what you have done so far? – scubaFun Jan 28 '15 at 18:20
  • Never try to call methods in an activity from any other class. The only public methods in a class should be the life cycle methods. Create a class to handle your loging/logout with a static members and static methods - or, better, create a singleton class. – Simon Jan 28 '15 at 18:26
  • Instead of having your application logic implemented within the activity, you should rather take that out to an external module and inject it in your activity using Dagger: http://stackoverflow.com/questions/27036933/how-to-set-up-dagger-dependency-injection-from-scratch-in-android-project – EpicPandaForce Jan 28 '15 at 18:51

1 Answers1

0

I solved it.The mistake when I call the activity again a new instance got created even the static objects didnt work. So I re initialized the GoogleAPIClient in the activity and in onConnected method I checked for the user if registered then call for signout() or else call signin().

Uday Naidu
  • 532
  • 1
  • 6
  • 16