NFC Action_Tech_Discovered with foreground dispatch won't catch Mifare 1k card
<p>I'm coding in C# with Xamarin and trying to scan a MIFARE Classic 1K card by NFC.</p>

<p>The intent-filter of m1card_test is working fine. But I don't want to select which Activity I want to start. So I'm trying to use the foreground dispatch.</p>

<p>Here is part of my code (C#):</p>

<ul>
<li><p><strong>OnCreate</strong></p>

<pre><code>Intent Myintent = new Intent(this, GetType());
Myintent.AddFlags(ActivityFlags.SingleTop);
mPendingIntent = PendingIntent.GetActivity(this, 0, Myintent, 0);

ndefDetected = new IntentFilter(NfcAdapter.ActionTechDiscovered);
ndefDetected.AddDataType("*/*");

intentF = new IntentFilter[] { ndefDetected };
techLists = new string[][] {new string[] {
    typeof(Android.Nfc.Tech.NfcA).FullName,
    typeof(Android.Nfc.Tech.MifareClassic).FullName}
};
</code></pre></li>
<li><p><strong>OnPause</strong></p>

<pre><code>NfcManager manager = (NfcManager)GetSystemService(NfcService);
manager.DefaultAdapter.DisableForegroundDispatch(this);
</code></pre></li>
<li><p><strong>OnResume</strong></p>

<pre><code>NfcManager manager = (NfcManager)GetSystemService(NfcService);
manager.DefaultAdapter.EnableForegroundDispatch(this,mPendingIntent,intentF,techLists);
</code></pre></li>
</ul>

<p>Unfortunately, the foreground dispatch doesn't work (i.e. it does not pick up the tag).</p>

<p>If I change the call to <code>EnableForegroundDispatch()</code> to</p>

<pre><code>manager.DefaultAdapter.EnableForegroundDispatch(this,mPendingIntent,null,null);
</code></pre>

<p>the foreground dispatch work fine. But it picks up all tags and not just MIFARE Classic and I get an intent Action_Tag_Discovered instead of Action_Tech_Discovered.</p>

<p>How to use Action_Tech_Discovered with foreground dispatch system?</p>

<p>Did I miss something?</p>

<hr>

<p>tech_list.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"&gt;
  &lt;tech-list&gt;
    &lt;tech&gt;android.nfc.tech.NfcA&lt;/tech&gt;
    &lt;tech&gt;android.nfc.tech.MifareClassic&lt;/tech&gt;
  &lt;/tech-list&gt;  
&lt;/resources&gt;
</code></pre>

<p>AndroidManifest.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="m1card_test.m1card_test" android:versionCode="1" android:versionName="1.0"&gt;
  &lt;uses-sdk android:minSdkVersion="16" /&gt;
  &lt;application android:label="m1card_test"&gt;&lt;/application&gt;
  &lt;uses-permission android:name="android.permission.NFC" /&gt;
&lt;/manifest&gt;
</code></pre>

<p>My C# code:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Nfc;

namespace m1card_test
{
    [Activity(Label = "m1_read",  Icon = "@drawable/icon", LaunchMode = Android.Content.PM.LaunchMode.SingleTask)]
    [IntentFilter(
    new[] {NfcAdapter.ActionTechDiscovered}, 
    Categories = new[] {Intent.CategoryDefault,})]
    [MetaData("android.nfc.action.TECH_DISCOVERED", Resource = "@xml/tech_list")]

    public class m1_read : Activity
    {
        TextView mTV;
        PendingIntent mPendingIntent;
        IntentFilter ndefDetected;
        IntentFilter[] intentF;
        String[][] techLists;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.m1_read);

            Intent Myintent = new Intent(this, GetType());
            Myintent.AddFlags(ActivityFlags.SingleTop);
            mPendingIntent = PendingIntent.GetActivity(this, 0, Myintent, 0);

            ndefDetected = new IntentFilter(NfcAdapter.ActionTechDiscovered);
            ndefDetected.AddDataType("*/*");

            intentF = new IntentFilter[] { ndefDetected };
            techLists = new string[][] {new string[] {
                typeof(Android.Nfc.Tech.NfcA).FullName,
                typeof(Android.Nfc.Tech.MifareClassic).FullName}
            };

            Button button = FindViewById&lt;Button&gt;(Resource.Id.Back_Button);
            mTV = FindViewById&lt;TextView&gt;(Resource.Id.textview);
            button.Click += delegate
            {
                Intent main_intent = new Intent(this, typeof(MainActivity));
                this.StartActivity(main_intent);
                Finish();
            };

        }
        protected override void OnPause()
        {
            base.OnPause();
            NfcManager manager = (NfcManager)GetSystemService(NfcService);
            manager.DefaultAdapter.DisableForegroundDispatch(this);
        }

        protected override void OnResume()
        {
            base.OnResume();
            NfcManager manager = (NfcManager)GetSystemService(NfcService);
            manager.DefaultAdapter.EnableForegroundDispatch(this, mPendingIntent,intentF,techLists);
        }

        protected override void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);
            mTV.Text = "OnNewIntent";
        }
    }
}
</code></pre>