我有一个nexus-s,并且我有一个nfc标记,其中写入了以下数据:
http://www.example.com/abc当nexus-s发现标记时,我会得到两个应用程序的列表,这些应用程序可以处理标记读取:
tags (included with the nexus-s I think)
MyTagReadingApp (my own demo app)这是我的演示应用程序清单:
<activity
android:name=".activities.ActivityReadTag"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>因此,我的应用程序在读取任何nfc标记时都会被调用。如果标签中有url数据,并且它是我特定的www.example.com域的一部分,我希望它只出现在能够处理标签读取的应用程序列表中。类似于:
<activity
android:name=".activities.ActivityReadTag"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="http"
android:host="www.example.com"
android:pathPattern="/" />
</intent-filter>
</activity>我希望这个标签能在这里起作用,但似乎不起作用。这种技术适用于其他地方的urls,比如超链接。不确定sdk是否支持这一点?
谢谢
查看DDMS,在与标签进行联系时,我看到了以下内容:
Starting: Intent {
act=android.nfc.action.NDEF_DISCOVERED
dat=http://example.com/foo/1234 flg=0x10000000 (has extras)
} from pid 246
Starting: Intent {
flg=0x10000000 cmp=com.android.nfc3/com.android.nfc.TechListChooserActivity
(has extras)
} from pid 246因此,我尝试更新我的清单如下:
<activity
android:name=".activities.ActivityReadTag"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action
android:name="android.nfc.action.NDEF_DISCOVERED" />但还是没有运气。我正在使用api 10 (2.3.3)。
发布于 2011-05-13 10:49:01
奇怪的是,它对我的关系很好,也许这就是你的意图
dat=http://example.com/foo/1234 flg=0x10000000 (has extras) 然而,您的应用程序将只响应WWW.example.com。我用example.com创建了一个标签,这个应用程序再也没有响应了。
发布于 2011-05-13 08:43:39
尝试添加动作android:name="android.intent.action.VIEW“
否则,应用程序将不会出现在应用程序选择器中。
剩下的过滤器在我看来没问题
https://stackoverflow.com/questions/5820599
复制相似问题