Android Question NFC Intent

akinnovation

Member
Licensed User
Longtime User
Hi,
I need to catch NfcV intent with my application, and I wish that it will resume and show app.
I have see the thread https://www.b4x.com/android/forum/threads/how-to-make-nfc-tag-trigger-application.73561/. I have copied the modify to manifest as write from Erel, but when I compile the project I had an error:
Generating R file. Error
AndroidManifest.xml:35: error: Error parsing XML: not well-formed (invalid token)

Where is my mistake ?

marco
 

Attachments

  • compileerror.jpg
    compileerror.jpg
    35.1 KB · Views: 319
  • manifest.jpg
    manifest.jpg
    119.7 KB · Views: 306

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi

Try this

B4X:
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.TAG_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.TECH_DISCOVERED"/>
             <category android:name="android.intent.category.DEFAULT"/>
             <data android:mimeType="text/plain" />
           </intent-filter>)
   
AddActivityText(Main,<meta-data
       android:name="android.nfc.action.TECH_DISCOVERED"
       android:resource="@xml/nfc_tech_filter"
           />)
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Also the 'nfc_tech_filter.xml' should look like this:

B4X:
<resources 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>android.nfc.tech.Ndef</tech>
  <tech>android.nfc.tech.NdefFormatable</tech>
  <tech>android.nfc.tech.MifareClassic</tech>
  <tech>android.nfc.tech.MifareUltralight</tech>
  </tech-list>
</resources>
 
Upvote 0

akinnovation

Member
Licensed User
Longtime User
Many thanks, now I can compile it I have added only:
B4X:
CreateResource(xml, nfc_tech_filter.xml,
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <tech-list>
  <tech>android.nfc.tech.NfcV</tech>
  </tech-list>
</resources>)
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Upvote 0

akinnovation

Member
Licensed User
Longtime User
This is the manifest editor source code
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
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.TAG_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.TECH_DISCOVERED"/>
             <category android:name="android.intent.category.DEFAULT"/>
             <data android:mimeType="text/plain" />
           </intent-filter>)
  
AddActivityText(Main,<meta-data
       android:name="android.nfc.action.TECH_DISCOVERED"
       android:resource="@xml/nfc_tech_filter"
           />)
CreateResource(xml, nfc_tech_filter.xml,
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <tech-list>
  <tech>android.nfc.tech.NfcV</tech>
  </tech-list>
</resources>)
 
Upvote 0

akinnovation

Member
Licensed User
Longtime User
Hi Erel when the app is in pause I don't see any intent I see only:
Check NDEF Failed - status = 3
START u0 {act=android.nfc.action.TAG_DISCOVERED flg=0x10020000 cmp=Advanced.Nfc/.main (has extras)} from uid 10177 on display 0
.....
Starting background presence check
START u0 {flg=0x10008000 cmp=com.android.nfc/.NfcRootActivity (has extras)} from uid 1027 on display 0
.....
START u0 {act=android.nfc.action.TAG_DISCOVERED (has extras)} from uid 1027 on display 0
and with the app running:
Connect to a tech with a different handle
Check NDEF Failed - status = 3
START u0 {act=android.nfc.action.TAG_DISCOVERED flg=0x10020000 cmp=Advanced.Nfc/.main (has extras)} from uid 10177 on display 0
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
AUDIO_OUTPUT_FLAG_FAST denied by client
Techs: [android.nfc.tech.NfcV, android.nfc.tech.NdefFormatable]

Thank you for your replies
 
Upvote 0

akinnovation

Member
Licensed User
Longtime User
Hi ,
I have found the trouble in the Manifest. Because I use blank tag I have deleted the
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>)
and to the other intent filter I have deleted only
<data android:mimeType="text/plain" />
and now the app will popoup at tag scanning.

Thank you for the forum support
 
Upvote 0
Top