Skip to content

[Android] Pass the launched extra when resuming WebAuthenticator #30583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protected override void OnCreate(Bundle savedInstanceState)
// start the intermediate activity again with flags to close the custom tabs
var intent = new Intent(this, typeof(WebAuthenticatorIntermediateActivity));
intent.SetData(Intent.Data);
intent.PutExtra(WebAuthenticatorIntermediateActivity.LaunchedExtra, true);
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
StartActivity(intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Microsoft.Maui.Authentication
[Activity(ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, Exported = false)]
class WebAuthenticatorIntermediateActivity : Activity
{
const string launchedExtra = "launched";
const string actualIntentExtra = "actual_intent";
internal const string LaunchedExtra = "launched";
internal const string ActualIntentExtra = "actual_intent";

bool launched;
Intent actualIntent;
Expand All @@ -26,11 +26,11 @@ protected override void OnCreate(Bundle savedInstanceState)
}

// read the values
launched = extras.GetBoolean(launchedExtra, false);
launched = extras.GetBoolean(LaunchedExtra, false);
#pragma warning disable 618 // TODO: one day use the API 33+ version: https://developer.android.com/reference/android/os/Bundle#getParcelable(java.lang.String,%20java.lang.Class%3CT%3E)
#pragma warning disable CA1422 // Validate platform compatibility
#pragma warning disable CA1416 // Validate platform compatibility
actualIntent = extras.GetParcelable(actualIntentExtra) as Intent;
actualIntent = extras.GetParcelable(ActualIntentExtra) as Intent;
#pragma warning restore CA1422 // Validate platform compatibility
#pragma warning restore CA1416 // Validate platform compatibility
#pragma warning restore 618
Expand Down Expand Up @@ -66,16 +66,16 @@ protected override void OnNewIntent(Intent intent)
protected override void OnSaveInstanceState(Bundle outState)
{
// save the values
outState.PutBoolean(launchedExtra, launched);
outState.PutParcelable(actualIntentExtra, actualIntent);
outState.PutBoolean(LaunchedExtra, launched);
outState.PutParcelable(ActualIntentExtra, actualIntent);

base.OnSaveInstanceState(outState);
}

public static void StartActivity(Activity activity, Intent intent)
{
var intermediateIntent = new Intent(activity, typeof(WebAuthenticatorIntermediateActivity));
intermediateIntent.PutExtra(actualIntentExtra, intent);
intermediateIntent.PutExtra(ActualIntentExtra, intent);

activity.StartActivity(intermediateIntent);
}
Expand Down
Loading