与BroadcastReceiver的Android的NFC标签接收 [英] Android NFC tag received with broadcastreceiver
问题描述
我试图抓住NFC标签的广播接收器,所以我写了一个打印ASD中的onReceive一个简单的BR()。在清单XML它的desribed这样的:
I'm trying to catch NFC tag in broadcast receiver so I wrote a simple BR that prints "asd" in the onReceive(). In the manifest xml it's desribed like that:
和我收到仅此打印可言......
and I receive only this and no print at all....
01-31 16:37:18.980: ERROR/MediaPlayer(990): setAudioStream called in state 8
01-31 16:37:18.980: ERROR/MediaPlayer(990): error (-38, 0)
01-31 16:37:18.980: ERROR/MediaPlayer(990): start called in state 0
01-31 16:37:18.980: ERROR/MediaPlayer(990): error (-38, 0)
01-31 16:37:18.988: ERROR/MediaPlayer(990): Error (-38,0)
当我使用的活动来处理这样的意图:
When I use activity to handle the intent like this:
<activity android:name="TagViewer"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
该活动开始,可以正常使用,所以我怎么能使其与BroadcastReceiver的工作?
The activity is started and working perfectly, so how can I make it work with BroadcastReceiver?
推荐答案
您可以写一个小的活动,不显示任何UI可言,发送广播消息,然后用抛光结束()。在清单中使用的标志,你能避免它显示了在历史上还是在最近通话和被faily无形的,希望得到一个类似的效果,你的愿望与braodcast接收器。
You could write a small activity that doesn't show any UI at all, sends a broadcast message and then ends with finish(). Using flags in the manifest you can avoid it showing up in history or in recents and being faily invisible, hopefully getting a similar effect to that you desire with the braodcast receiver.
这篇关于与BroadcastReceiver的Android的NFC标签接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!