Note that there are some explanatory texts on larger screens.

plurals
  1. PONFC - Not able to detect a tag
    primarykey
    data
    text
    <p>onNewIntent(Intent intent) method not getting called.</p> <p>The code i am trying is </p> <pre><code>public class NfcTagDetector extends Activity{ private NfcAdapter mNfcAdapter; private PendingIntent pendingIntent; private IntentFilter[] intentFiltersArray; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.detect_tag); pendingIntent = PendingIntent.getActivity( this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); IntentFilter discovery=new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter techDetected = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); // Intent filters for writing to a tag intentFiltersArray = new IntentFilter[] { discovery,ndefDetected,techDetected }; } public void onPause() { super.onPause(); mNfcAdapter.disableForegroundDispatch(this); } public void onResume() { super.onResume(); mNfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFiltersArray, null); } @Override protected void onNewIntent(Intent intent) { // TODO Auto-generated method stub super.onNewIntent(intent); Log.e("TAP", "onNewIntent"); } </code></pre> <p>}</p> <p>And AndroidManifest.xml</p> <pre><code>&lt;activity android:name="com.example.detect.NfcTagDetector" &gt; &lt;intent-filter&gt; &lt;action android:name="android.nfc.action.TECH_DISCOVERED" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" /&gt; &lt;/activity&gt; </code></pre> <p>nfc_tech_filter.xml file is </p> <pre><code>&lt;resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"&gt; &lt;tech-list&gt; &lt;tech&gt;android.nfc.tech.IsoDep&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.NfcA&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.NfcB&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.NfcF&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.NfcV&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.Ndef&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.NdefFormatable&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.MifareClassic&lt;/tech&gt; &lt;tech&gt;android.nfc.tech.MifareUltralight&lt;/tech&gt; &lt;/tech-list&gt; </code></pre> <p></p> <p>Please help...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload