46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Android.App;
|
|
using Android.Content;
|
|
using Android.Content.PM;
|
|
using Android.Nfc;
|
|
using Android.OS;
|
|
using NFCLockDemoV2;
|
|
using NFCLockDemoV2.Platforms.Android;
|
|
using System.Diagnostics;
|
|
|
|
namespace NFCLockAppV2;
|
|
|
|
[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)]
|
|
[IntentFilter(new[] { Intent.ActionMain }, Categories = new[] { Intent.CategoryLauncher })]
|
|
[IntentFilter(new[] { NfcAdapter.ActionNdefDiscovered, NfcAdapter.ActionTechDiscovered, NfcAdapter.ActionTagDiscovered }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "text/plain")]
|
|
public class MainActivity : MauiAppCompatActivity
|
|
{
|
|
private NFCLockHelper nfcHelper;
|
|
private NFCCallbacks _callbacks;
|
|
|
|
protected override void OnCreate(Bundle savedInstanceState)
|
|
{
|
|
base.OnCreate(savedInstanceState);
|
|
_callbacks = new NFCCallbacks();
|
|
nfcHelper = new NFCLockHelper(this, _callbacks);
|
|
|
|
}
|
|
|
|
protected override void OnResume()
|
|
{
|
|
base.OnResume();
|
|
nfcHelper.OnResume();
|
|
}
|
|
|
|
protected override void OnPause()
|
|
{
|
|
base.OnPause();
|
|
nfcHelper.OnPause();
|
|
}
|
|
|
|
protected override void OnNewIntent(Intent intent)
|
|
{
|
|
base.OnNewIntent(intent);
|
|
nfcHelper.OnNewIntent(intent);
|
|
|
|
}
|
|
} |