Ejemplo n.º 1
0
 public override bool ShouldOverrideUrlLoading(WebView view, string url)
 {
     if (url.IndexOf(Constact.Callback) > -1)
     {
         Uri uri   = new Uri(url.Replace("#", "?"));
         var query = uri.Query.TrimStart('?').Split('&');
         foreach (var item in query)
         {
             var q = item.Split('=');
             if (q[0] == "code")
             {
                 var code = q[1];
                 System.Diagnostics.Debug.Write(code);
                 Token token = AccessTokenUtil.GetToken(context);
                 AuthorizationRequest.Authorization_Code(token, code, (userToken) =>
                 {
                     System.Diagnostics.Debug.Write(userToken.access_token);
                     UserTokenUtil.SaveToken(userToken, context);
                     // ActivityCompat.FinishAfterTransition(context);
                     context.StartActivity(new Intent(context, typeof(MainActivity)));
                     MobclickAgent.OnProfileSignIn(code);
                 },
                                                         error =>
                 {
                     MobclickAgent.ReportError(context, "µÇ¼ʧ°Ü" + error);
                     System.Diagnostics.Debug.Write(error);
                 });
             }
         }
         // view.stoploading();
     }
     return(base.ShouldOverrideUrlLoading(view, url));
 }
Ejemplo n.º 2
0
 public void Logout()
 {
     UserTokenUtil.SaveToken(new ApiModel.Token(), context);
 }