You can go back to your app if you add this code to the end of OnCreate method in the class that captures the Redirect (CustomUrlSchemeInterceptorActivity) in Xamarin.Auth example in Android
new Task(() =>{
StartActivity(new Intent(Application.Context,typeof(MainActivity)));
}).Start();
Where MainActivity is the name of your main Activity class in Android.
To be more exact here is a complete class that you can inherit for each redirection you intercept
public class UrlSchemeInterceptor : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
try
{
base.OnCreate(savedInstanceState);
// Convert Android.Net.Url to Uri
var uri = new Uri(Intent.Data.ToString());
new Task(() =>
{
var intent = new Intent(ApplicationContext, typeof(MainActivity));
intent.AddFlags(ActivityFlags.IncludeStoppedPackages);
intent.AddFlags(ActivityFlags.ReorderToFront);
StartActivity(intent);
}).Start();
// Load redirectUrl page
AuthenticationState.Authenticator.OnPageLoading(uri);
Finish();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
public class AuthenticationState
{
public static WebAuthenticator Authenticator;
/*This static field is used to store the object
from OAuth1Authenticator or OAuth2Authenticator
upon initialization in the UI (Xamarin forms or Android or iOS).
For example:
var authenticatorObject = new OAuth2Authenticator (YOUR PARAMETERS);
AuthenticationState.Authenticator = (WebAuthenticator)authenticatorObject;
var presenter = new OAuthLoginPresenter();
presenter.Login(authenticatorObject);
*/
}
For example in Google Case
[Activity(Label = "YOURLABEL", NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
[IntentFilter( new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataSchemes = new[]
{
"com.googleusercontent.apps.",// YOUR GOOGLE ID INVERTED
},
DataPaths = new[]
{
"/oauth2redirect",
})]
public class GoogleUrlSchemeInterceptorActivity : UrlSchemeInterceptor { }