private void EnableReaderMode() { Activity activity = this.Activity; NfcAdapter nfc = NfcAdapter.GetDefaultAdapter(activity); if (nfc != null) { nfc.EnableReaderMode(activity, mLoyaltyCardReader, READER_FLAGS, null); } }
public async Task StartCardReaderAsync(string deviceId) { await Task.Run(() => { NfcAdapter nfc = NfcAdapter.GetDefaultAdapter(activity); if (nfc != null) { nfc.EnableReaderMode(activity, this, READER_FLAGS, null); } }); }
private void EnableReaderMode() { Console.WriteLine("Enabling reader mode"); Field.Text = "Waiting..."; Activity activity = this.Activity; NfcAdapter nfc = NfcAdapter.GetDefaultAdapter(activity); if (nfc != null) { nfc.EnableReaderMode(activity, callbackClass, READER_FLAGS, null); } }
private void EnableReaderMode() { Log.Info(TAG, "Enabling reader mode"); Activity activity = this; NfcAdapter nfc = NfcAdapter.GetDefaultAdapter(activity); if (nfc != null) { nfc.EnableReaderMode(activity, _smartHotelCardReader, READER_FLAGS, null); } }
//Start NFC reader public void StartListening() { Activity activity = CrossCurrentActivity.Current.Activity; NfcAdapter nfc = NfcAdapter.GetDefaultAdapter(activity); CardReaderService callback = new CardReaderService(); if (nfc != null) { Console.WriteLine("[CODE] Reader Started"); nfc.EnableReaderMode(activity, callback, READER_FLAGS, null); } }
void Start(object sender, EventArgs args) { try { nfc = NfcAdapter.GetDefaultAdapter(this); // NfcReaderFlags flags = NfcReaderFlags.NfcA | NfcReaderFlags.NfcB | NfcReaderFlags.NfcBarcode | NfcReaderFlags.NfcF | NfcReaderFlags.NfcV | NfcReaderFlags.SkipNdefCheck; NfcReaderFlags flags = NfcReaderFlags.NfcA | NfcReaderFlags.SkipNdefCheck; nfc.EnableReaderMode(this, readerCallback, flags, null); } catch (Exception ex) { TextView textViewTag = FindViewById <TextView> (Resource.Id.textViewTag); textViewTag.Text = ex.Message; } }
public async Task StartReadingAsync() { if (!await IsReaderAvailableAsync()) { throw new InvalidOperationException("NFC reader not available"); } if (!await IsReaderEnabledAsync()) { throw new InvalidOperationException("NFC reader is not enabled"); } var act = CurrentActivity; var tagDetected = new IntentFilter(NfcAdapter.ActionNdefDiscovered); tagDetected.AddDataType("*/*"); var filters = new[] { tagDetected }; var intent = new Intent(act, act.GetType()).AddFlags(ActivityFlags.SingleTop); var pendingIntent = PendingIntent.GetActivity(act, 0, intent, 0); _nfcAdapter.EnableReaderMode(act, this, NfcReaderFlags.NfcA | NfcReaderFlags.NoPlatformSounds, null); }
public async Task StartListeningAsync() { if (!await IsAvailableAsync()) { throw new InvalidOperationException("NFC not available"); } if (!await IsEnabledAsync()) // todo: offer possibility to open dialog { throw new InvalidOperationException("NFC is not enabled"); } var activity = CrossNfc.CurrentActivity; var tagDetected = new IntentFilter(NfcAdapter.ActionNdefDiscovered); tagDetected.AddDataType("*/*"); var filters = new[] { tagDetected }; var intent = new Intent(activity, activity.GetType()).AddFlags(ActivityFlags.SingleTop); var pendingIntent = PendingIntent.GetActivity(activity, 0, intent, 0); _nfcAdapter.EnableForegroundDispatch(activity, pendingIntent, filters, new[] { new[] { Java.Lang.Class.FromType(typeof(Ndef)).Name } }); _nfcAdapter.EnableReaderMode(activity, this, NfcReaderFlags.NfcA | NfcReaderFlags.NoPlatformSounds, null); }
private async Task PlatformScanAsync(NdefScanOptions options = null) { s_adapter.EnableReaderMode(Xamarin.Essentials.Platform.CurrentActivity, this, NfcReaderFlags.NfcA | NfcReaderFlags.NfcB | NfcReaderFlags.NfcF | NfcReaderFlags.NfcV, null); }