Couldn't open an APK File with NFC

PfJuliPfJuli Member ✭✭

At first I want say, that I made many things with C#, but don't have much experience in Xamarin. So please don't kill me if my question is silly. ;)
I have just tried to add NFC in my a Xamarin App. I did it it like there:
I have written the code nearly exactly like in this post and also created a file named xml under Resources with techlist.xml in it. It all workde fine and I have installed the App on my phone, but I couldn'T open it. I found the App in the App-List, but there wasn't a way to open it. When I tried to launch it in the Android Emulator the App just didn't open. If you need more information please contact me. Thank you very much!

using Android.App;
using Android.Widget;
using Android.OS;
using Android.Nfc;
using System.Text;

namespace NFC
    [Activity(Label = "NFC", MainLauncher = false), IntentFilter(new[] { "android.nfc.action.TECH_DISCOVERED"
        Categories = new[] {

    [MetaData("android.nfc.action.TECH_DISCOVERED", Resource =
    public class TransactionActivity : Activity

        protected string TagUid;
        protected override void OnResume()
            TextView idtext = FindViewById<TextView>(Resource.Id.textView1);
            if (NfcAdapter.ActionTechDiscovered.Equals(Intent.Action))
                var MyTag = Intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
                if (MyTag != null)
                    var tagId = MyTag.GetId();
                    TagUid = ByteArrayToString(tagId);
                    idtext.Text = TagUid;

        private static string ByteArrayToString(byte[] ba)
            var hex = new StringBuilder(ba.Length * 2);
            foreach (byte b in ba)
                hex.AppendFormat("{0:x2}", b);
            return hex.ToString();
        //  public class MainActivity : Activity
        //  {
        //     protected override void OnCreate(Bundle savedInstanceState)
        //     {
        //     }
        //  }


Sign In or Register to comment.