protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); buttonLaunch = FindViewById <Button>(Resource.Id.buttonLaunch); buttonLaunch.Click += LaunchButton_OnClick; buttonLaunch.Visibility = Android.Views.ViewStates.Invisible; textMessages = FindViewById <TextView>(Resource.Id.textViewDevice); TextView text = FindViewById <TextView>(Resource.Id.textViewDevice); text.Text = "Touch Tag to Device"; //StartActivityForResult(intent, (int)ActivityCode.NFCPair); nfcAdapter = NfcAdapter.GetDefaultAdapter(this); NFCPairLib.NewInstance(this.ApplicationContext, this, 0); }
protected override void OnNewIntent(Intent intent) { Intent returnedIntent = NFCPairLib.OnNewIntent(intent); if (returnedIntent != null) { string deviceName = returnedIntent.GetStringExtra("NFCDeviceName"); string deviceAddress = returnedIntent.GetStringExtra("NFCDeviceAddress"); if ((deviceName != null) && (deviceAddress != null)) { textMessages.Text = string.Format("{0}, {1}", deviceName, deviceAddress); } else { textMessages.Text = string.Format("{0}", returnedIntent.GetStringExtra("ErrorMessage")); } } else { textMessages.Text = "Pairing failed"; } }