android - How to know if app is authorize by user to use Google Play Game Services -
android - How to know if app is authorize by user to use Google Play Game Services -
i'm using gpgs in app achievements. connect gpgs on startup can load , set user achievements. want connect if user before connected clicking connect button in app.
use case 1:
- user opens app - app not connect gpgs
use case 2:
- user opens app - clicks button connect gpgs - closes app days later - user opens app - app connects gpgs
i used store boolean flag in shared prefs know if app authorized. problem have no way know when user signs out in achievements activity or disconnects app in devices google settings.
what like
if(mgoogleapiclient.isautorized(){ mgoogleapiclient.connect(); }
any ideas how can figure out if app authorized?
when phone call mgoogleapiclient.connect()
, not visible user unless login successful (and banner appears profile picture).
you have phone call result.startresolutionforresult()
result
onconnectionfailed
start user visible login flow. long don't phone call until user clicks login button you'll have behavior want.
note if using gamehelper
/basegameactivity
classes, may need disable default behavior of auto-login , phone call beginuserinitiatedsignin()
(which above startresolutionforresult()
phone call you) when user clicks login button.
the faq states:
[4] why gamehelper/basegameactivity attempting sign in on application startup?
the default behavior of basegameactivity , gamehelper show user sign-in flow (consent dialogs, etc) application starts. naturally, 1 time user signs in first time, won't see consent flow again, seamless experience. of import user sign in possible application can take advantage of google play games api right away (for example, saving user's progress using cloud save, unlocking achievements, etc). if user cancels sign-in flow, basegameacitivity/gamehelper remember cancellation. if total number of cancellations reaches predefined maximum (by default, 3), user no longer prompted sign in on application startup. if happens, can still sign in clicking application's sign in button, if provide one.
[5] don't new "auto sign in" feature of gamehelper. how can disable it?
to disable feature , homecoming old behavior, can edit gamehelper.java , set default_max_sign_in_attempts constant 0, or phone call gamehelper.setmaxautosigninattempts(0) @ runtime, before calling gamehelper.setup() (or, correspondingly, activity's oncreate method).
android google-play-games
Comments
Post a Comment