需要假NFC标签被扫描在Android中 [英] Need To Fake an NFC Tag Being Scanned In Android

查看:159
本文介绍了需要假NFC标签被扫描在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个应用程序。当一个NFC标签,任何标记,扫描这个程序将只完成一项任务。唯一的问题,我没有任何NFC标签。我试图消除需要一个卡,无论如何,所以我需要的是假/让它看上去就像一个NFC标签被扫描的方法。我可以写应用程序和这样让我真正需要的是核心code键使机器人认为标签被扫描。我可以做休息。我只需要能够按一个按钮,然后Android的认为一个标签被扫描,这样应用程序将被调用。谢谢你们

Ok, I have an app. This app will only complete a task when an nfc tag, any tag, is scanned. Only problem, I do not have any nfc tags. And I am trying to eliminate needing a card anyway, So What I need is a way to "Fake/Make It Look" Like an nfc tag has been scanned. I can write apps and such so all I really need is the core code to make android think a tag was scanned. I can do the rest. I just need to be able to push a button, then android think that a tag was scanned so that the app will be invoked. Thank You Guys

推荐答案

编写播放您想一经推出效仿NFC的意图,然后关闭应用程序。因此,一个简单的应用程序与大致做到这一点在它的onCreate一个活动:

Write an app that broadcasts the NFC intent you'd like to emulate upon launch, and then closes. So a simple app with a single activity that does roughly this in its onCreate:

       Intent intent = new Intent("android.nfc.action.NDEF_DISCOVERED");
       startActivity(intent);
       finish();

然后您的应用程序应该自愿来处理它,仿佛它已被读取NFC读写。

Then your app should volunteer to handle it as though it had been read with an NFC reader.

在年底托马斯是正确的,你应该买一个NFC标签,并用它做,你知道它是做你想让它正常的NFC标签是什么方式。

In the end Thomas is right, you should just buy an NFC tag and be done with it, that way you know that it's doing what you want it to for normal nfc tags.

如果无法很好地浮起你的船,另一种选择是增加一个长期运行的通知,在其的点击,它的意图播出。这样,您就不必再回到主菜单,以得到它的工作。

If that doesn't quite float your boat, another option is to add a long-running notification, upon the click of which, it does the intent broadcast. This way you won't have to go back to the main menu to get it to work.

这篇关于需要假NFC标签被扫描在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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