From d232fbc68cb4ac32a8d76e90d598c851bbf8770f Mon Sep 17 00:00:00 2001 From: Ghander Date: Sun, 8 Jun 2025 15:00:27 -0500 Subject: [PATCH] initialize nfc plugin --- .../Platforms/Android/MainActivity.cs | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/BTCPayApp.Maui/Platforms/Android/MainActivity.cs b/BTCPayApp.Maui/Platforms/Android/MainActivity.cs index 3dad452..7ad2493 100644 --- a/BTCPayApp.Maui/Platforms/Android/MainActivity.cs +++ b/BTCPayApp.Maui/Platforms/Android/MainActivity.cs @@ -11,31 +11,31 @@ namespace BTCPayApp.Maui; ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] public class MainActivity : MauiAppCompatActivity { - //protected override void OnCreate(Android.OS.Bundle? savedInstanceState) - //{ - // base.OnCreate(savedInstanceState); - // // Initialize NFC Plugin - // CrossNFC.Init(this); - //} + protected override void OnCreate(Android.OS.Bundle? savedInstanceState) + { + base.OnCreate(savedInstanceState); + // Initialize NFC Plugin + CrossNFC.Init(this); + } - //protected override void OnResume() - //{ - // base.OnResume(); - // CrossNFC.OnResume(); + protected override void OnResume() + { + base.OnResume(); + CrossNFC.OnResume(); - // var nfcAdapter = NfcAdapter.GetDefaultAdapter(this); - // if (nfcAdapter != null) - // { - // var intent = new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop); - // var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.Immutable); - // nfcAdapter.EnableForegroundDispatch(this, pendingIntent, null, null); - // } - //} + var nfcAdapter = NfcAdapter.GetDefaultAdapter(this); + if (nfcAdapter != null) + { + var intent = new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop); + var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.Immutable); + nfcAdapter.EnableForegroundDispatch(this, pendingIntent, null, null); + } + } - //protected override void OnNewIntent(Intent? intent) - //{ - // base.OnNewIntent(intent); - // // Handle NFC tag discovery - // CrossNFC.OnNewIntent(intent); - //} + protected override void OnNewIntent(Intent? intent) + { + base.OnNewIntent(intent); + // Handle NFC tag discovery + CrossNFC.OnNewIntent(intent); + } }