Note that there are some explanatory texts on larger screens.

plurals
  1. POIntent.getAction results in NULL
    primarykey
    data
    text
    <p>I was trying to implement the sample code for the NFC viewer from android developers, but I'm not recieving any action from my intent, here is my code:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tag_viewer); mTagContent = (LinearLayout) findViewById(R.id.list); mTitle = (TextView) findViewById(R.id.title); final Intent queryIntent = getIntent(); final String queryAction = queryIntent.getAction(); if (Intent.ACTION_SEARCH.equals(queryAction)) { onNewIntent(getIntent()); } else { //nothing } // resolveIntent(getIntent()); } void resolveIntent(Intent intent) { // Parse the intent final String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) { // When a tag is discovered we send it to the service to be save. We // include a PendingIntent for the service to call back onto. This // will cause this activity to be restarted with onNewIntent(). At // that time we ryead it from the database and view it. Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] msgs; if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i &lt; rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } } else { // Unknown tag type byte[] empty = new byte[] {}; NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty); NdefMessage msg = new NdefMessage(new NdefRecord[] {record}); msgs = new NdefMessage[] {msg}; } // Setup the views // setTitle(R.string.); buildTagViews(msgs); } else { Log.e(TAG, "Unknown intent " + intent); finish(); return; } } @Override public void onNewIntent(final Intent newIntent) { super.onNewIntent(newIntent); final Intent queryIntent = getIntent(); setIntent(queryIntent); resolveIntent(queryIntent); } </code></pre> <p>And the intent filter:</p> <pre><code> &lt;activity android:name="TagReader_BuiltIn" android:launchMode="singleTop"&gt; &lt;intent-filter&gt; &lt;action android:name="android.nfc.action.TAG_DISCOVERED"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;/intent-filter&gt; </code></pre> <p>the intent.getAction(); Always results in NUll, any ideas? thanks in advance</p>
    singulars
    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