Hi All,
I'm playing around with some NFC tags (old ski card pass...) which are not NDEF ones.
I understood from Android APi doc that those tags should send an ACTION_TECH_DISCOVERED intend when tapped.
I therefore wanted to see if I could trap the intent with an empty activity like this one :
I added this to the manifest:
and I also copied a read only tech_filter.xml file in the adhoc directory :
Now, with all this, the results are:
- with a NDEF tag including a text record ==> the intent is received and the app is shown in the list of applications available
- with the same NDEF tag but fully erased ==> the apk does not receive the intent
- with the skypass tag ==> no reception of the intent neither
What am I doing wrong ? Please help this drives me crazy !
I'm playing around with some NFC tags (old ski card pass...) which are not NDEF ones.
I understood from Android APi doc that those tags should send an ACTION_TECH_DISCOVERED intend when tapped.
I therefore wanted to see if I could trap the intent with an empty activity like this one :
B4X:
#Region Project Attributes
#ApplicationLabel: NFC-TEST
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Globals
End Sub
Sub Process_Globals
'Dim NFC As NFC,
Dim LastIntent As Intent
Dim uid As String
Dim bytc As ByteConverter
End Sub
Sub Activity_Resume
If Activity.GetStartingIntent = LastIntent Then Return
LastIntent = Activity.GetStartingIntent
End Sub
I added this to the manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddActivityText(main, <intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
</intent-filter>)
AddActivityText(main, <intent-filter>
<action android:name="android.nfc.action.ACTION_TECH_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>)
AddActivityText(Main,<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/tech_filter" />)
and I also copied a read only tech_filter.xml file in the adhoc directory :
B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcB</tech>
</tech-list>
</resources>
Now, with all this, the results are:
- with a NDEF tag including a text record ==> the intent is received and the app is shown in the list of applications available
- with the same NDEF tag but fully erased ==> the apk does not receive the intent
- with the skypass tag ==> no reception of the intent neither
What am I doing wrong ? Please help this drives me crazy !