从市场越权QUOT NFC应用;采用&QUOT完成操作;对话框项 [英] NFC applications from market override "Complete action using" dialog entries

查看:201
本文介绍了从市场越权QUOT NFC应用;采用&QUOT完成操作;对话框项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 NXP TagWriter 并的 NFC TagInfo在Nexus S,用于NFC我的应用程序开发的相同设备 。问题是我的应用程序没有在完成动作使用标签后,对话框被读取,只有无论是从市场安装所示。调试了一段时间后,我一直在使用演示应用尝试,结果是相同。我缺少的是在这里吗?难道应用程序都必须从市场上安装才能有意图过滤器正确解析?

更新

我的意图过滤器只是

 <意向滤光器>
  <作用机器人:名字=android.nfc.action.TAG_DISCOVERED/>
  <类机器人:名字=android.intent.category.DEFAULT/>
&所述; /意图滤光器>

我曾尝试加入其他如手动指定一个接之一,也是一起没有成功。难道有事可做MIME类型?

当NFC标签被读取,只有这两条线相关的行动,并没有别的。

 信息/ ActivityManager(111):开始:意向{行动= android.nfc.action.TECH_DISCOVERED FLG = 0x10000000的CMP = com.nxp.nfc.tagwriter / .activities.DashboardActivity(有演员)}从PID 197
信息/ ActivityManager(111):开始:意向{CMP = com.nxp.nfc.tagwriter / .activities.ConfirmLicenseActivity}从PID 6250

看到 android.nfc.action.TECH_DISCOVERED 被触发时,我加入了以下意图过滤器:

 <意向滤光器>
    <作用机器人:名字=android.nfc.action.TECH_DISCOVERED/>
    <类机器人:名字=android.intent.category.DEFAULT/>
&所述; /意图滤光器><元数据机器人:名字=android.nfc.action.TECH_DISCOVERED
           机器人:资源=@ XML / nfc_tech_filter/>

RES / XML / nfc_tech_filter.xml 包含

 <资源的xmlns:XLIFF =瓮:绿洲:名称:TC:XLIFF:文件:1.2>
    <科技的列表>
        <技术与GT; android.nfc.tech.IsoDep< /高科技>
        <技术与GT; android.nfc.tech.NfcA< /高科技>
        <技术与GT; android.nfc.tech.NfcB< /高科技>
        <技术与GT; android.nfc.tech.NfcF< /高科技>
        <技术与GT; android.nfc.tech.NfcV< /高科技>
        <技术与GT; android.nfc.tech.Ndef< /高科技>
        <技术与GT; android.nfc.tech.NdefFormatable< /高科技>
        <技术与GT; android.nfc.tech.MifareClassic< /高科技>
        <技术与GT; android.nfc.tech.MifareUltralight< /高科技>
    < /科技的列表>
< /资源>


解决方案

原因TAG_DISCOVERED不会弹出你的应用程序,是因为它是后备选项:只有当无法找到的NDEF_DISCOVERED和TECH_DISCOVERED意图的比赛, TAG_DISCOVERED将出动。

由于NXP应用程序注册TECH_DISCOVERED,他们将在pferred您的应用程序$ P $。您的解决方案包括一个TECH_DISCOVERED过滤器是正确的,但是你做的方式是错误的。在技术列表块的技术是AND-ED一起;所以在你的榜样,这意味着该过滤器将只匹配有NFCA和NfcB和MifareClassic标签。由于NFCA和NfcB是非常不同的技术,不走在一起,这个过滤器永远不会匹配。

您真正想要的是所有不同技术的OR。要做到这一点,只需写只包含一个技术多块:

 <科技的列表>
    <技术与GT; android.nfc.tech.NfcA< /高科技>
< /科技的列表>
<科技的列表>
    <技术与GT; android.nfc.tech.NfcB< /高科技>
< /科技的列表>

这将匹配NFCA或NfcB。当然,你应该让你的过滤器尽可能准确,以prevent从重挫了应用程序列表。如果您在NFCA标签是唯一的兴趣,不主张别人。

I have installed NXP TagWriter and NFC TagInfo on Nexus S, the same device used for my NFC application development. The problem is my application is not shown in the "Complete action using" dialog after Tag is read, only both installed from market are. After debugging it for a while, I have tried using demo application and the result was the same. What am I missing here? Do applications have to be installed from the market in order to have intent filters parsed properly?

Update

My intent-filter was simply

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

I have tried adding others as specified in manual, one by one as well as all together without success. Could it have something to do with mime type?

When NFC tag is read, only these two lines are related to 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

Seeing android.nfc.action.TECH_DISCOVERED is triggered, I have added following intent-filter:

<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>

解决方案

The reason TAG_DISCOVERED does not pop up your app is because it is the fall-back option: only when no matches for the NDEF_DISCOVERED and TECH_DISCOVERED intents can be found, TAG_DISCOVERED will be dispatched.

Since the NXP apps register for TECH_DISCOVERED, they will be preferred over your app. Your solution to include a TECH_DISCOVERED filter is correct, but the way you do it is wrong. The technologies in a "tech-list" block are AND-ed 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 don't go together, this filter will never match.

What you really want is an OR of all the different technologies. To do that, simply write multiple 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 application list from clobbering up. If you're only interested in NfcA tags, don't claim the others.

这篇关于从市场越权QUOT NFC应用;采用&QUOT完成操作;对话框项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆