Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid NFC Startup screen
    primarykey
    data
    text
    <p>I am trying to read an NFC tag, when I click a button on my app. Currently I am able to detect the tag in default mode (Tag app installed in Nexus phone). but I am not able to get to display the activity chooser through which I want to launch my tag</p> <pre><code>public class NFC_button extends Activity { protected IntentFilter ifilter ; private NfcAdapter adapter; private BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] ndefmessages; if(messages != null) { ndefmessages = new NdefMessage[messages.length]; for(int i = 0;i&lt;messages.length;i++) { ndefmessages[i] = (NdefMessage)messages[i]; } } } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); adapter=NfcAdapter.getDefaultAdapter(this); ifilter = new IntentFilter(); ifilter.addAction("android.nfc.action.NDEF_DISCOVERED"); ifilter.addCategory("android.intent.category.LAUNCHER"); } @Override protected void onResume() { registerReceiver(receiver, ifilter); super.onResume(); } } &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nfc.example" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-permission android:name="android.permission.NFC"/&gt; &lt;uses-feature android:name="android.hardware.nfc" android:required="true"/&gt; &lt;uses-sdk android:minSdkVersion="10"/&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".NFC_ExampleActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".NFC_button"&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p></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