| Electronic Components Datasheet Search |
|
AN4430 Datasheet(PDF) 24 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN4430 Datasheet(HTML) 24 Page - STMicroelectronics |
|
24 / 42 page ![]() How to create an Android Application for ST dual memories AN4430 24/42 DocID025722 Rev 1 2.5.2 NFC Adapter and foreground Dispatch Involving with NFC sub system requires retrieving the reference of the NFC adapter. In onCreate() callback developer grabs a reference to the NFC adapter: Add a new class member to the activity class. This mAdapter reference allows to listening the tag being scanned: Retrieve the default NFC adapter on component creation: In order to declare the application to grab NFC intents and to answer to all NFC intent while the activity is running (see activity lifecycle stage1) NFC dispatch capabilities has to be called in onResume() and disabled in onpause() callbacks. With the previous enableForegroundDispatch(), activity is declared as a grabber of whole NFC intents while the activity is in foreground state. It’s possible to add filter to only grab specific NFC intents like ACTION_TAG_DISCOVERED ones. In onResume() call back, it may then possible to declare a filter and configure the default NfcAdapter with: 2.5.3 Intents and NFC objects treatment If the MainActivity has been started by the Android System on NFC intent, the activity has to retrieve the intent and treat it. This can be done on activity creation (onCreate() callback call) by the following implementation: NfcAdapter mAdapter; mAdapter = NfcAdapter.getDefaultAdapter(this); @Override public void onResume() { super.onResume(); PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); NfcAdapter.getDefaultAdapter(this).enableForegroundDispatch(this,intent, null, null); } @Override protected void onPause() { super.onPause(); if (NfcAdapter.getDefaultAdapter(this) != null) NfcAdapter.getDefaultAdapter(this).disableForegroundDispatch(this); } PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter tagtoHandle = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter[] filters = new IntentFilter[] { tagtoHandle }; mAdapter.enableForegroundDispatch(this, pendingIntent, filters, null); |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |