NFC applications from Market Override "Complete with" dialog entries

I installed the NXP TagWriter and NFC TagInfo on Nexus S, the same device used for the development of NFC applications. The problem is that my application does not appear in the "Complete action using" dialog after reading the tag, only those installed from the market. After some debugging, I tried using a demo application and the result was the same. What am I missing here? Should applications be installed from the market in order to properly configure intent filters?

Update

My filter intent was just

<intent-filter> <action android:name="android.nfc.action.TAG_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> 

I tried to add others, as indicated in the manual , one by one, and also all together without success. Could this have anything to do with the mime type?

When an NFC tag is read, only these two lines are associated with the action and nothing else.

 INFO/ActivityManager(111): Starting: Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x10000000 cmp=com.nxp.nfc.tagwriter/.activities.DashboardActivity (has extras) } from pid 197 INFO/ActivityManager(111): Starting: Intent { cmp=com.nxp.nfc.tagwriter/.activities.ConfirmLicenseActivity } from pid 6250 

If you see android.nfc.action.TECH_DISCOVERED , I added the following filter intent:

 <intent-filter> <action android:name="android.nfc.action.TECH_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" /> 

And res/xml/nfc_tech_filter.xml contains

 <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> 
+4
source share
2 answers

The reason TAG_DISCOVERED does not appear in your application because it is a return option: only if no matches are found for NDEF_DISCOVERED and TECH_DISCOVERED, TAG_DISCOVERED will be sent.

Since NXP application applications are registered for TECH_DISCOVERED, they will be preferable to your application. Your decision to enable the TECH_DISCOVERED filter is correct, but the way you do it is incorrect. Technologies in the "tech-list" AND-ed block together; so in your example, this means that the filter will only match tags that have NfcA and NfcB and MifareClassic. Since NfcA and NfcB are very different technologies that are not combined, this filter will never match.

What you really want is the OR of all the different technologies. To do this, simply write a few blocks containing only one technology:

 <tech-list> <tech>android.nfc.tech.NfcA</tech> </tech-list> <tech-list> <tech>android.nfc.tech.NfcB</tech> </tech-list> 

This will match NfcA OR NfcB. Of course, you should make your filter as accurate as possible to prevent the list of applications from overflowing. If you are only interested in NfcA tags, do not require others.

+13
source

Your technical list should consist of a combination of technologies that, in your opinion, are supported by your card. For example, if the card you want to read has NfcA, NfcB and MifareClassic, then your technical list should have:

 <tech-list> <tech>android.nfc.tech.NfcA</tech> <tech>android.nfc.tech.NfcB</tech> <tech>android.nfc.tech.MifareClassic</tech> </tech-list> 

Your resources may have more than one tech-list tag. Only if the tag matches one of the technical lists in your resources will your application be detected.

0
source

Source: https://habr.com/ru/post/1346201/


All Articles