读取NFC标签只能从particuar活动 [英] Reading NFC tags only from a particuar activity

查看:174
本文介绍了读取NFC标签只能从particuar活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伊利诺伊州第一个告诉你,我在做什么。我有三个活动的顺序,

Ill first tell you what I am doing. I have three activities in the sequence,

活动1 >>活性2 >> Activity3。现在,我想读NFC标签只能从活性2,当我点击这个标签。我的应用程序不应该是能够读取标签,当我在活动1或Activity3。我怎么到这一点,是否有任何启用/禁用选项?任何财产为同一组?我不想提示用户从设置用于此目的启用/禁用的NFC

Activity1>>Activity2>>Activity3. Now I want to read NFC tags only from the Activity2 when I tap on the tag. My app should not be able to read the tags when I am in the Activity1 or Activity3. How am I supposed to this, Is there any enabling/disabling option? any property to set for the same? I dont want to prompt the user to enable/disable NFC from the Settings for this purpose.

推荐答案

作为前台应用程序,你的应用程序将始终有机会就摸标记的第一反应。所以,你需要做的是让forgraoundDsipatch为你的活动,并在活动1和Activity3只是忽略的事件,以及活性2的过程中触及标签的信息。否则,如果您的应用程序不采取检测的标签的情况下,Android的调度系统将继续寻找合适的应用程序触发,当它发现它会启动它在你的应用程序之上。

As a foreground application, your app will always have the chance to react first on the touched tag. So what you need to do is to enable forgraoundDsipatch for your activities, and on Activity1 and Activity3 just to ignore the event, and on Activity2 process the information of the touched tag. Otherwise if your app do not take the event of the detected tag, the android dispatch system will continue to search suitable application to trigger and when it find it it will start it on top of your app.

有关前景派遣更多的信息,请看这里:<一href="http://developer.android.com/guide/topics/nfc/advanced-nfc.html#foreground-dispatch">http://developer.android.com/guide/topics/nfc/advanced-nfc.html#foreground-dispatch

For more information on Foreground Dispatch look here: http://developer.android.com/guide/topics/nfc/advanced-nfc.html#foreground-dispatch

这篇关于读取NFC标签只能从particuar活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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