admin管理员组文章数量:1305304
Getting Exception in MAUI app while trying to implement biometric on maui android using plugin.Fingerprint
the exception says: {System.InvalidOperationException: Resolver for the current activity is not set. Call Fingerprint.SetCurrentActivityResolver somewhere in your startup code.
however this is my mainactivity.cs
namespace dummy
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density, Exported = true)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
CrossFingerprint.SetCurrentActivityResolver(() => this);
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
and here is how i implemented the authentication:
public async Task biometric()
{
try
{
var availability = await CrossFingerprint.Current.IsAvailableAsync();
if (!availability)
{
//await MainThread.InvokeOnMainThreadAsync(async () =>
//{
// await DisplayAlert("Warning!", "No biometrics available", "OK");
//});
return;
}
var authResult = await CrossFingerprint.Current.AuthenticateAsync(
new AuthenticationRequestConfiguration(
"Login to dummy",
"Unlock your device to use dummy."));
if (authResult.Authenticated)
{
if (!string.IsNullOrEmpty(usrname) && !string.IsNullOrEmpty(pasword))
{
AutoLogin(usrname, pasword);
}
else
{
await DisplayAlert("Error", "Login details missing!", "OK");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
本文标签:
版权声明:本文标题:c# - Resolver for the current activity is not set. Call Fingerprint.SetCurrentActivityResolver somewhere in your startup code - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741766556a2396494.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论