diff options
author | Peter Rustler <peter.rustler@basyskom.com> | 2015-01-14 15:56:05 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-02-02 08:01:44 +0000 |
commit | 7f1f193529f464c6a99aebab1b41821159b02cff (patch) | |
tree | dd95a10c0ab86faccdc8c928017c34a3e09144dc /src | |
parent | 48ad3a42f841f00ea5bca835597a3cc0c80df5b4 (diff) |
Removed the listening for other tags than ndef
The current implementation of nfc for Android
does not support other nfc tags than ndef.
This patch removes the listening for other tag
technologies.
Change-Id: Id8303e50bd52d641b6de8d382e485ba7417e8c09
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java index 2e6cb959..b838fac1 100644 --- a/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java +++ b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java @@ -104,8 +104,24 @@ public class QtNfc m_activity.runOnUiThread(new Runnable() { public void run() { //Log.d(TAG, "Enabling NFC"); + IntentFilter[] filters = new IntentFilter[2]; + filters[0] = new IntentFilter(); + filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); + filters[0].addCategory(Intent.CATEGORY_DEFAULT); try { - m_adapter.enableForegroundDispatch(m_activity, m_pendingIntent, null, null); + filters[0].addDataType("*/*"); + } catch (MalformedMimeTypeException e) { + throw new RuntimeException("Check your mime type."); + } + // some tags will report as tech, even if they are ndef formated/formatable. + filters[1] = new IntentFilter(); + filters[1].addAction(NfcAdapter.ACTION_TECH_DISCOVERED); + String[][] techList = new String[][]{ + {"android.nfc.tech.Ndef"}, + {"android.nfc.tech.NdefFormatable"} + }; + try { + m_adapter.enableForegroundDispatch(m_activity, m_pendingIntent, filters, techList); } catch(IllegalStateException e) { throw new RuntimeException("Fail", e); } |