从应用程序内禁用NFC功能 [英] Disable NFC functionality from within the app

查看:373
本文介绍了从应用程序内禁用NFC功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要解决的问题如下:

NFC标签将触发我的应用程序,从中启动另一个应用程序.有时会发生的事情是,NFC标签将移动并被手机发现",并再次启动我的应用程序.我无法控制NFC标签的移动.

An NFC tag will trigger my app, from which I'm launching another app. What sometimes will happen is that the NFC tag will move and will be "re discovered" by the phone and launch my app once again. The moving of the NFC tag is something I can't control.

这真的破坏了体验.

理想情况下,我希望启动我的应用程序后,NFC触发将被禁用或暂停,并且一旦应用程序关闭(OnDestroy()),我将启用/取消暂停NFC功能.

What I would ideally like to do is once my app is launched, NFC triggering will be disabled or paused, and once app is closed (OnDestroy()) I will enable / un-pause NFC functionality.

我找不到解决方法,您的帮助将不胜感激.如果您有另一种(与代码相关的)解决方法,那么效果也一样.

I couldn't find how this could be done and your help would be really appreciated. If you have another (code related) approach on how this can be solved, this is just as good.

几年前,我注意到了这篇文章: NFC禁用适配器 但是我希望有另一种解决方案,不能将系统应用程序作为选择,并且提示用户禁用NFC同样糟糕...

I noticed this post from a couple years back : NFC disable adapter But I hope there is another solution, being a system application is not an option and prompting the user the disable NFC is just as bad...

先谢谢了.

推荐答案

您可以创建活动别名来处理意图,禁用(如果您的活动正在运行),并且在销毁它后重新启用它.

You can create an activity-alias that handles the intent, disable it while your activity is running and re-enable it when it is destroyed.

这篇关于从应用程序内禁用NFC功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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