Code example for IntentFilter

Methods: addDataType

0
		// Handle all of our received NFC intents in this activity. 
		mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
				getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
 
		// Intent filters for reading a note from a tag or exchanging over p2p. 
		IntentFilter ndefDetected = new IntentFilter(
				NfcAdapter.ACTION_NDEF_DISCOVERED);
		try { 
			ndefDetected.addDataType("state/data");
		} catch (MalformedMimeTypeException e) {
			// Handle Properly 
		} 
		mNdefExchangeFilters = new IntentFilter[] { ndefDetected };
 
		// Intent filters for writing to a tag 
		IntentFilter tagDetected = new IntentFilter(
				NfcAdapter.ACTION_TAG_DISCOVERED);
		mWriteTagFilters = new IntentFilter[] { tagDetected };
 
	}