protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
#endif
        {
            base.OnElementChanged(e);
#if !__IOS__
            if (App.inAuthentication)
            {
                return;
            }
            App.inAuthentication = true;
            // this is a ViewGroup - so should be able to load an AXML file and FindView<>

            var auth = new RefreshOAuth2Authenticator(
                Constants.ClientId,
                Constants.ClientSecret,
                Constants.Scopes,
                new Uri(Constants.AuthorizationUri),
                new Uri(Constants.RedirectUri),
                new Uri(Constants.AccessTokenUri));

            auth.AllowCancel = true;

            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    App.SuccessfulLoginAction.Invoke();
                }

                var request = new OAuth2Request("GET", new Uri("https://www.googleapis.com/oauth2/v2/userinfo"), null,
                                                eventArgs.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    userJson = response.GetResponseText();
                }
                StoringDataIntoCache(userJson, eventArgs.Account);
            };

            //TODO: Fix the output error
            //auth.ShowErrors = false;
            var activity = Forms.Context as Activity;
            activity.StartActivity(auth.GetUI(activity));
#endif
        }
        public override void ViewDidAppear(bool animated)
        {
            if (App.inAuthentication)
            {
                return;
            }
            base.ViewDidAppear(animated);
            var auth = new RefreshOAuth2Authenticator(
                Constants.ClientId,
                Constants.ClientSecret,
                Constants.Scopes,
                new Uri(Constants.AuthorizationUri),
                new Uri(Constants.RedirectUri),
                new Uri(Constants.AccessTokenUri));

            auth.AllowCancel = true;

            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    App.SuccessfulLoginAction.Invoke();
                    App.inAuthentication = true;
                }

                var request = new OAuth2Request("GET", new Uri("https://www.googleapis.com/oauth2/v2/userinfo"), null,
                                                eventArgs.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    userJson = response.GetResponseText();
                }
                StoringDataIntoCache(userJson, eventArgs.Account);
            };
            auth.ShowErrors = false;
            PresentViewController(auth.GetUI(), true, null);
        }