2

I've integrated new Google SignIn api for Android in app following the documentation.

But I've some doubts about the best way to manage the credentials in application lifecycle and across all the applications activities and services.

Doubts:

  1. Retrieve credentials in an initial activity and store globally for usage on other activities is an anti pattern, or is something that can be done?
  2. If it's not good to store credentials, then for each activity or service that potentially needs credentials it has to call singleSignIn(). Because there isn't another way to ask if credentials are present, is there?
  3. If you go for a solution like 2 any recommendation to maintain code clean and don't propagate credentials logic too much at every place? My best idea now is to manage silent signIn in a BaseActivity that every activity inherits and if silent login it's not possible (with cached or trying to retrieve credentials) then redirect to a full dedicated Login Activity.
lujop
  • 13,504
  • 9
  • 62
  • 95
  • Possible duplicate of [How to correctly use Google Plus Sign In with multiple activities?](https://stackoverflow.com/questions/22368520/how-to-correctly-use-google-plus-sign-in-with-multiple-activities) – Duane Sep 18 '18 at 01:02
  • This question has some discussion on this question: [how to correctly use google plus signin with multiple activities](https://stackoverflow.com/questions/22368520/how-to-correctly-use-google-plus-sign-in-with-multiple-activities) – Duane Sep 18 '18 at 01:04

0 Answers0