예제 #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
        {
            int resultCodeInt = (int)resultCode;

            if (requestCode != RequestCode)
            {
                return;
            }

            AuthenticationResponse response = AuthenticationClient.GetResponse(resultCodeInt, intent);

            if (response.GetType() == AuthenticationResponse.Type.Token)
            {
                TextView successTextView = FindViewById <TextView>(Resource.Id.success_text_view);
                successTextView.Text = "";

                Log.Debug("SpotifyAuth", $"Auth token: {response.AccessToken}");

                ISharedPreferencesEditor editor = GetSharedPreferences("SPOTIFY", 0).Edit();
                editor.PutString("token", response.AccessToken);
                editor.Commit();

                Intent i = new Intent(this, typeof(MainActivity));
                StartActivity(i);
            }
            else
            {
                TextView successTextView = FindViewById <TextView>(Resource.Id.success_text_view);
                successTextView.Text = "Failed to login";

                Log.Debug("SpotifyAuth", $"Auth error: {response.Error}");
            }
        }