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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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();
Then your app should volunteer to handle it as though it had been read with an NFC reader.
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.