Note that there are some explanatory texts on larger screens.

plurals
  1. POListening for credit card info with NFC
    primarykey
    data
    text
    <p>Is there any working sample on how to create sample app listening for credit card presence?</p> <p>I tried this piece of code from Android samples but nothing happens when I scan the card (<code>NFC</code> is working I hear the beep sound)</p> <pre><code> public class MainActivity extends Activity { private NfcAdapter mAdapter; private PendingIntent mPendingIntent; private IntentFilter[] mFilters; private String[][] mTechLists; private TextView mText; private int mCount = 0; @Override public void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.activity_main); mAdapter = NfcAdapter.getDefaultAdapter(this); mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); try { ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } mFilters = new IntentFilter[] { ndef, }; mTechLists = new String[][] { new String[] { NfcF.class.getName() } }; } @Override public void onResume() { super.onResume(); mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists); String action = getIntent().getAction(); //allways MAIN, even after scanning a card Parcelable[] msg1 = getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); //allways null Parcelable[] msg2 = getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_TAG); //allways null } @Override public void onNewIntent(Intent intent) { Log.i("Foreground dispatch", "Discovered tag with intent: " + intent); mText.setText("Discovered tag " + ++mCount + " with intent: " + intent); } @Override public void onPause() { super.onPause(); mAdapter.disableForegroundDispatch(this); } } </code></pre> <p>Maybe there is something wrong with my <code>Manifest</code> file:</p> <p> </p> <pre><code>&lt;uses-sdk android:minSdkVersion="16" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.NFC" /&gt; &lt;uses-feature android:name="android.hardware.nfc" android:required="true" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="pl.aprilapps.nfcreader.MainActivity" 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;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; &lt;intent-filter&gt; &lt;action android:name="android.nfc.action.NDEF_DISCOVERED" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="text/plain" /&gt; &lt;/intent-filter&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.
    plurals
    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