Exemplo n.º 1
0
        protected override void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);
            Tag tag = (Android.Nfc.Tag)intent.GetParcelableExtra(NfcAdapter.ExtraTag);

            Log.Debug("TAG", "onNewIntent: " + intent.Action);

            if (tag != null)
            {
                var ndef = Ndef.Get(tag);
                if (isDialogDisplayed)
                {
                    if (ndef == null)
                    {
                        Toast.MakeText(Android.App.Application.Context, "Tipo de cartão não suportado.", ToastLength.Short).Show();
                    }
                    else if (isWrite)
                    {
                        string messageToWrite = editMesagemPadrao.Text;
                        if (messageToWrite.Equals(""))
                        {
                            Toast.MakeText(Android.App.Application.Context, "Preencha uma mensagem", ToastLength.Short).Show();
                        }
                        else
                        {
                            mNfcWriteFragment = (NFCWriteFragment)FragmentManager.FindFragmentByTag(NFCWriteFragment.TAG);
                            mNfcWriteFragment.OnNfcDetected(ndef, messageToWrite);
                        }
                    }
                    else if (isRead)
                    {
                        mNfcReadFragment = (NFCReadFragment)FragmentManager.FindFragmentByTag(NFCReadFragment.TAG);
                        mNfcReadFragment.OnNfcDetected(ndef);
                    }
                    else if (isFormat)
                    {
                        nfcFormatFragment = (NFCFormatFragment)FragmentManager.FindFragmentByTag(NFCFormatFragment.TAG);
                        nfcFormatFragment.OnNfcDetected(ndef);
                    }
                    else if (isForceTeste)
                    {
                        nfcWriteReadFragment = (NFCWriteReadFragment)FragmentManager.FindFragmentByTag(NFCWriteReadFragment.TAG);
                        nfcWriteReadFragment.onNfcDetected(ndef, MENSAGEM_PADRAO + processo);
                        processo--;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ShowReadWriteFragment()
        {
            isForceTeste = true;
            isFormat     = false;
            isRead       = false;
            isWrite      = false;
            processo     = 1000;

            nfcWriteReadFragment = (NFCWriteReadFragment)FragmentManager.FindFragmentByTag(NFCWriteReadFragment.TAG);

            if (nfcWriteReadFragment == null)
            {
                nfcWriteReadFragment = NFCWriteReadFragment.NewInstance();
            }
            nfcWriteReadFragment.Show(FragmentManager, NFCWriteReadFragment.TAG);
        }