from the previous NFC support type of card read, the following is to solve the NFC blocking response, if this step is not done, when the system has a number of NFC-enabled applications, will be in the NFC swipe when the number of application options, we need the scene is, The current app requires NFC to swipe, and the app intercepts intent distribution (using theForeground Dispatch System).
Specific scenarios:
1. Create pendingintent to distribute the activity you want to respond to
Mpendingintent = pendingintent.getactivity (this, 0, new Intent (this, nfcactivity.class). Addflags (Intent.flag_ Activity_single_top), 0);
2. When swiping, use the intent filter to filter out the intent you want to intercept.
Intentfilter ndef = new Intentfilter (nfcadapter.action_ndef_discovered); try { ndef.adddatatype ("*/*"), } catch (Intentfilter.malformedmimetypeexception e) { throw new RuntimeException ("fail", E); } Intentfiltersarray = new Intentfilter[]{ndef,};
3. Set the tag technologies you want to handle in the string array
Techlistsarray = new String[][]{new String[]{nfca.class.getname ()}};
4. Set the Nfcadapter in Onresume and OnPause
public void OnPause () { super.onpause (); Madapter.disableforegrounddispatch (this);} public void Onresume () { super.onresume (); Madapter.enableforegrounddispatch (This, pendingintent, Intentfiltersarray, Techlistsarray);}
Of course, before you define Nfcadapter
Nfcadapter = Nfcadapter.getdefaultadapter (this);
This problem to solve the experience of one thing, this issue in the domestic blog forum has not been searched, there is an article on the StackOverflow
http://stackoverflow.com/questions/16542147/ How-to-read-nfc-tags-to-prevent-system-dialogs-nfc-starter-list-and-tags-being-d
The link inside is the Android develop ... NFC foreground dispatching.
All the basic tutorials can be found in the developer, no longer blind toss, there are problems to find Google
The current app intercepts the NFC response and does not pop up the selection box tutorial