Code example for NfcManager

Methods: getDefaultAdapter

0
		}; 
		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
				new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
		 
		NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
		NfcAdapter adapter = manager.getDefaultAdapter();
		adapter.enableForegroundDispatch(this, pendingIntent, writeTagFilters, null);
	} 
	 
	boolean writeTag(NdefMessage message, Tag tag) {
		try { 
			Ndef ndef = Ndef.get(tag);
			if (ndef != null) {
				return writeToTag(message, ndef);
			} else { 
				NdefFormatable format = NdefFormatable.get(tag);
				if (format != null) {
					if(formatAndWrite(format, message)) {
						return true; 
					} else { 
						toast(getString(R.string.write_tag_failed_format));