Code example for NfcAdapter

Methods: enableForegroundDispatchisEnabled

        if (!inReadMode) {
            if (nfcAdapter != null && nfcAdapter.isEnabled()) {
                // Handle all of our received NFC intents in this activity. 
                Intent intent = new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
                        | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                PendingIntent nfcPendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
                // Intent filters for reading a note from a tag or exchanging over p2p. 
                IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
                IntentFilter[] ndefExchangeFilters = new IntentFilter[]{tagDetected};
                nfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, ndefExchangeFilters, null);
Connect your IDE to all the code out there  Get Codota for Java