I'm working on a payment application and the global idea is to convert the smartphone into a POS (Mobile POS)
I've searched a lot on the web (and here too !), I found answers to a part of all my questions but it remains one problem.
Everything seems to be correct, but the card isn't detected by the smartphone...
Here is my Manifest.xml (important parts...)
<uses-feature
android:name="android.hardware.nfc"
android:required="true"/>
<use-permission
android:name="android.permission.NFC"/>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android.resource="@xml/nfc_tech_list"/>
In my nfc_tech_list.xml I put IsoDep, NfcA and NfcB.
For the moment, I just have one activity. Here's the code :
private Toolbar mToolbar;
private NfcAdapter mNfcAdapter;
private final byte[] SELECT_PPSE = {
(byte) 0x00, // CLA
(byte) 0xA4, // INS
(byte) 0x04, // P1
(byte) 0x00, // P2
(byte) 0x0E, // Lc
0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x20, 0x31,
(byte) 0x00
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Setting the Action Bar
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
// Checking if the NFC is enabled
mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (!mNfcAdapter.isEnabled())
Toast.makeText(this.getBaseContext(), "Veuillez activer le NFC dans vos paramètres", Toast.LENGTH_LONG).show();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// Is the intent for a new NFC Tag Discovery
if (intent != null && intent.getAction() == NfcAdapter.ACTION_TECH_DISCOVERED) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
IsoDep isoDep = IsoDep.get(tag);
if (isoDep == null)
Toast.makeText(this.getBaseContext(), "Bon début", Toast.LENGTH_LONG).show();
else
Toast.makeText(this.getBaseContext(), "Mauvais début", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onResume() {
super.onResume();
mNfcAdapter.enableForegroundDispatch(this,
PendingIntent.getActivity(this,
0,
new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0),
new IntentFilter[]{new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED)},
new String[][]{new String[]{IsoDep.class.getName()}}
);
The problem is that the card isn't detected at all whereas other tags are...
Can anybody help me ?
EDIT : I'm working with a Galaxy Note 3 Lite
EDIT 2 : Here's my techlist :
<?xml version="1.0" encoding="utf-8"?>
<resource xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.NfcB</tech>
<tech>android.nfc.tech.NfcF</tech>
<tech>android.nfc.tech.NfcV</tech>
</tech-list>
</resource>
Could you post your tech list, maybe? You might be unintentionally excluding the card from your filter. What tech(s) do you expect the card to match on?
EDIT: Try this:
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcB</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcF</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcV</tech>
</tech-list>