mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-06-11 02:53:23 +02:00
Added: NFC Intent for Machine
This commit is contained in:
@ -4,30 +4,28 @@ using Android.Content.PM;
|
||||
using Android.OS;
|
||||
using AndroidX.AppCompat.App;
|
||||
using Java.Interop;
|
||||
using System;
|
||||
|
||||
namespace Borepin.Droid
|
||||
{
|
||||
[Activity(MainLauncher = true, Exported = true, Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
[Activity(MainLauncher = true, Exported = true, Theme = "@style/MainTheme", LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
[IntentFilter(
|
||||
new[]
|
||||
{
|
||||
"android.nfc.action.NDEF_DISCOVERED"
|
||||
"android.nfc.action.NDEF_DISCOVERED",
|
||||
"android.intent.action.VIEW",
|
||||
},
|
||||
Categories = new[]
|
||||
Categories = new[]
|
||||
{
|
||||
Intent.CategoryDefault
|
||||
Intent.CategoryDefault,
|
||||
Intent.CategoryBrowsable
|
||||
},
|
||||
DataScheme = "fabaccess",
|
||||
DataHost = "innovisionlab.de"
|
||||
DataScheme = "fabaccess"
|
||||
)]
|
||||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
{
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
Android.Net.Uri test = Intent.Data;
|
||||
string text = Intent.GetStringExtra("MyData") ?? "Data not available";
|
||||
|
||||
|
||||
AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
|
||||
|
||||
TabLayoutResource = Resource.Layout.Tabbar;
|
||||
@ -39,10 +37,22 @@ namespace Borepin.Droid
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
|
||||
Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App(new PlatformInitializer()));
|
||||
|
||||
Android.Net.Uri intentdata = Intent.Data;
|
||||
Uri uri = null;
|
||||
if (intentdata != null)
|
||||
{
|
||||
uri = new Uri(intentdata.ToString());
|
||||
}
|
||||
LoadApplication(new App(new PlatformInitializer(), uri));
|
||||
}
|
||||
protected override void OnNewIntent(Intent intent)
|
||||
{
|
||||
if(intent.Action == "android.nfc.action.NDEF_DISCOVERED")
|
||||
{
|
||||
intent.SetAction(Intent.ActionView);
|
||||
}
|
||||
|
||||
base.OnNewIntent(intent);
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ namespace Borepin.Droid
|
||||
[Application(Label = "FabAccess", Icon = "@mipmap/ic_launcher")]
|
||||
public class MainApplication : Application
|
||||
{
|
||||
public MainApplication(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user