private void Service_AuthTokenCompleted(object sender, AuthenticationTokenGetCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)sender;
            service.AuthenticationTokenGetCompleted -= Service_AuthTokenCompleted;

            if (e.Error != null)
            {
                Guid result = e.Result;
                string error = result.ToString(), errorOut = "";
                if (result == Guid.Empty)
                {
                    errorOut = Application.Context.Resources.GetString(Resource.String.authNoDeviceIDSent);
                    RunOnUiThread(delegate
                    {
                        GeneralUtils.Alert(c, Application.Context.Resources.GetString(Resource.String.errorAuthError), errorOut);
                    });
                }
            } else
            {
                AndroidData.ServiceAuthToken = e.Result.ToString();
                userlogin();
            }
        }
        private void Service_AuthenticationTokenGetCompleted(object sender, AuthenticationTokenGetCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)sender;
            service.AuthenticationTokenGetCompleted -= Service_AuthenticationTokenGetCompleted;

            string activityMessage = user == UserType.NewUser ?
                 Application.Context.Resources.GetString(Resource.String.loginRegisteringUser) :
                 Application.Context.Resources.GetString(Resource.String.loginLoggingIn);

            parent.RunOnUiThread(delegate
            {
                Toast.MakeText(c, activityMessage, ToastLength.Short).Show();
            });

            if (null == e.Error)
            {
                Guid result = e.Result;
                if (!result.Equals(Guid.Empty))
                {
                    AndroidData.ServiceAuthToken = result.ToString();

                    AccountOAuth accountAuth = new AccountOAuth();
                    User userObj = null;
                    ISocialProviderManager provider = (ISocialProviderManager)e.UserState;

                    try
                    {
                        userObj = provider.GetUserInfoObject(accountAuth);
                    } catch (Exception ex)
                    {
                        parent.RunOnUiThread(delegate
                        {
                            GeneralUtils.Alert(c, Application.Context.Resources.GetString(Resource.String.loginAuthError),
                                string.Format("{0} {1}", Application.Context.Resources.GetString(Resource.String.errorCouldNotGetUserInfoFormat), ex.Message), parent);
                        });
            #if DEBUG
                        System.Diagnostics.Debug.WriteLine("Problem with authenticating using {0}. Message = {1}. StackTrace = {2}", accountAuth.OAuthType.ToString(), ex.Message, ex.StackTrace);
            #endif
                        return;
                    }//end try catch

                    if (user == UserType.NewUser)
                    {
                        service.UserCreateCompleted += Service_UserCreateCompleted;
                        service.UserCreateAsync(AndroidData.NewDeviceID,
                                        DeviceDeviceTypes.Android,
                                        accountAuth.OAuthType,
                                        accountAuth.OAuthID,
                                        accountAuth.OAuthToken,
                                        userObj.FirstName,
                                        userObj.LastName,
                                        userObj.EmailAddress, string.Empty,
                                        userObj.Picture,
                                        userObj.DateOfBirth,
                                        string.Empty, // username
                                        string.Empty, // description
                                        0, // latitude
                                        0, // longtitude
                                        false, //showLocation
                                        false, // allowLocationSearch
                                        false, // allowSearch
                                        User.Gender.Male, // gender
                                        new Guid(AndroidData.ServiceAuthToken), accountAuth);

                    } else
                    {
                        service.UserLoginCompleted += Service_UserLoginCompleted;
                        service.UserLoginAsync(AndroidData.NewDeviceID,
                                               DeviceDeviceTypes.Android,
                                               LOLConstants.DefaultGuid,
                                               accountAuth.OAuthID,
                                               accountAuth.OAuthToken,
                                               accountAuth.OAuthType,
                                               userObj.EmailAddress,
                                               string.Empty,
                                               new Guid(AndroidData.ServiceAuthToken));
                    }//end if else
                } else
                {
                    parent.RunOnUiThread(delegate
                    {
                        GeneralUtils.Alert(c, Application.Context.Resources.GetString(Resource.String.loginAuthError), Application.Context.Resources.GetString(Resource.String.authNotAuthenticated), parent);
                    });
                }//end if else
            } else
            {
            #if(DEBUG)
                System.Diagnostics.Debug.WriteLine("Exception in AuthenticationTokenGetCompleted! {0}--{1}", e.Error.Message, e.Error.StackTrace);
            #endif
                parent.RunOnUiThread(delegate
                {
                    GeneralUtils.Alert(c, Application.Context.Resources.GetString(Resource.String.loginAuthError), Application.Context.Resources.GetString(Resource.String.authNotAuthenticated), parent);
                });
            }//end if else
        }
        private void Service_AuthenticationTokenGetCompleted(object s, AuthenticationTokenGetCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)s;
            service.AuthenticationTokenGetCompleted -= Service_AuthenticationTokenGetCompleted;

            if (e.Error == null) {
                Guid result = e.Result;
                if (!result.Equals (Guid.Empty)) {
                    AndroidData.ServiceAuthToken = result.ToString ();
                    service.UserGetResetTokenCompleted += Service_UserGetResetTokenCompleted;
                    service.UserGetResetTokenAsync (emailAddress, new Guid (AndroidData.ServiceAuthToken));
                } else {
                    RunOnUiThread (() => GeneralUtils.Alert (c, Application.Context.GetString (Resource.String.commonError),
                                                        Application.Context.GetString (Resource.String.errorAuthError)));
                }
            } else
                RunOnUiThread (() => Finish ());
        }
        private void Service_AuthenticationTokenGetCompleted(object sender, AuthenticationTokenGetCompletedEventArgs e)
        {
            bool t = false;
            byte[] cropped = null;
            LOLConnectClient service = (LOLConnectClient)sender;
            service.AuthenticationTokenGetCompleted -= Service_AuthenticationTokenGetCompleted;

            if (null == e.Error)
            {
                Guid result = e.Result;

                if (!result.Equals(Guid.Empty))
                {
                    AndroidData.ServiceAuthToken = result.ToString();

                    if (AndroidData.imageFileName != "")
                    {
                        Stream fs = File.Open(AndroidData.imageFileName, FileMode.Open);
                        Android.Graphics.Bitmap bmp = Android.Graphics.BitmapFactory.DecodeStream(fs);
                        MemoryStream stream = new MemoryStream();
                        bmp.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 70, stream);
                        cropped = stream.ToArray();
                        fs.Dispose();
                        stream.Dispose();
                        bmp.Dispose();
                        t = true;
                    }

                    service.UserCreateCompleted += Service_UserCreateCompleted;
                    service.UserCreateAsync(AndroidData.NewDeviceID,
                                            DeviceDeviceTypes.Android,
                                            AccountOAuth.OAuthTypes.LOL,
                                            string.Empty, string.Empty,
                                            firstName.Text,
                                            lastName.Text,
                                            email.Text,
                                            password.Text,
                                            t == true ? cropped : new byte[0],
                                            dob,
                                            username.Text, // username
                                            description.Text, // description
                                            location [0], // latitude
                                            location [1], // longitude
                                            q1, // showLocation
                                            q2, // allowLocSearch
                                            q3, // allowSearch
                                            gender, // gender
                                            new Guid(AndroidData.ServiceAuthToken));

                } else
                {
                    RunOnUiThread(delegate
                    {
                        if (progress != null)
                            progress.Dismiss();
                        GeneralUtils.Alert(context, Application.Context.Resources.GetString(Resource.String.commonError),
                                    Application.Context.Resources.GetString(Resource.String.authAccountIDNotToken));
                        EnableAll();
                    });
                }
            } else
            {
                RunOnUiThread(delegate
                {
                    if (progress != null)
                        progress.Dismiss();
                    GeneralUtils.Alert(context, Application.Context.Resources.GetString(Resource.String.commonError),
                                Application.Context.Resources.GetString(Resource.String.authAccountIDNotToken));
                    EnableAll();
                });
            }
        }
        private void Service_AuthenticationTokenGetCompleted(object sender, AuthenticationTokenGetCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)sender;
            service.AuthenticationTokenGetCompleted -= Service_AuthenticationTokenGetCompleted;

            if (null == e.Error)
            {
                Guid result = e.Result;

                if (!result.Equals(Guid.Empty))
                {
                    AndroidData.ServiceAuthToken = result.ToString();

                    service.UserCreateCompleted += Service_UserCreateCompleted;
                    service.UserCreateAsync(AndroidData.NewDeviceID,
                                             DeviceDeviceTypes.Android,
                                             AccountOAuth.OAuthTypes.LOL,
                                             string.Empty, string.Empty,
                                             first,
                                             last,
                                             email,
                                             password,
                                             image,
                                             dob,
                                             username, // username
                                             describe, // description
                                             location [0], // latitude
                                             location [1], // longitude
                                             q1, // showLocation
                                             q2, // allowLocSearch
                                             q3, // allowSearch
                                             gender, // gender
                                             new Guid(AndroidData.ServiceAuthToken));

                } else
                {
                    RunOnUiThread(delegate
                    {
                        if (progress != null)
                            progress.Dismiss();
                        GeneralUtils.Alert(context, Application.Context.Resources.GetString(Resource.String.commonError),
                                  Application.Context.Resources.GetString(Resource.String.authAccountIDNotToken));
                    });
                }
            } else
            {
                RunOnUiThread(delegate
                {
                    if (progress != null)
                        progress.Dismiss();
                    GeneralUtils.Alert(context, Application.Context.Resources.GetString(Resource.String.commonError),
                              Application.Context.Resources.GetString(Resource.String.authAccountIDNotToken));
                });
            }
        }