Best code examples for Android Tag class (android.nfc.Tag)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Tag class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Tag examples from Open Source projects
This code example shows how to use the following methods: getId, getTechList
        mTagId     = tagId;
        mScannedAt = scannedAt;
    } 
 
    public static Card dumpTag(byte[] tagId, Tag tag) throws Exception {
        final String[] techs = tag.getTechList();
        if (ArrayUtils.contains(techs, "android.nfc.tech.NfcB"))
            return CEPASCard.dumpTag(tag);
        else if (ArrayUtils.contains(techs, "android.nfc.tech.IsoDep"))
            return DesfireCard.dumpTag(tag);
        else if (ArrayUtils.contains(techs, "android.nfc.tech.NfcF"))
            return FelicaCard.dumpTag(tagId, tag);
        else if (ArrayUtils.contains(techs, "android.nfc.tech.MifareClassic"))
            return ClassicCard.dumpTag(tagId, tag);
        else 
            throw new UnsupportedTagException(techs, Utils.getHexString(tag.getId()));
    } 
 
    public static Card fromXml (String xml) throws Exception {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(new InputSource(new StringReader(xml)));
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: get
	private static final int PAGE_LENGTH = 4;
 
	MifareUltralight mifareUltralight;
	 
	public MifareUltralightTagHandler(Tag tag) {
		super(tag);
		mifareUltralight = MifareUltralight.get(tag);
	} 
 
	public byte[] readAll() throws CouldNotReadTagDataException { 
		try { 
			mifareUltralight.connect();
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			for (int page16 = 0; page16 < 4; page16++) {
				int blockA = page16 * 4;
				byte[] responseBytes = mifareUltralight.transceive(MiFareCommandFactory.readTagForBlock(blockA).toBytes());
				Log.d(TAG, "Read page16=" + page16 + " : " + HexFormatter.toHexString(responseBytes));
				// Extract the relevant part 
				output.write(responseBytes, 0, responseBytes.length);
			} 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getTechList, get
		String message = Coupon + "./" + DisplaycountDecrement();
		listrecord[RecordNum] = newTextRecord(message, Locale.JAPANESE, true);
		NdefMessage ndefmessage = new NdefMessage(listrecord);
 
		try { 
			if (Arrays.asList(tag.getTechList()).contains(Ndef.class.getName())) {
				Ndef ndef = Ndef.get(tag);
				try { 
					// ���ڑ����������ڑ�. 
					if (!ndef.isConnected()) {
						ndef.connect();
					} 
					// �����”\���`�F�b�N 
					if (ndef.isWritable()) {
						// ���� 
						ndef.writeNdefMessage(ndefmessage);
						Log.d("NFC", "�������ݐ���");
					} else { 
						Log.d("NFC", "�������ݕs��");
					} 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getTechList, get
	void writeNdefMessage(Tag tag) {
 
		NdefMessage message = generateNdefMessage();
 
		try { 
			if (Arrays.asList(tag.getTechList()).contains(
					NdefFormatable.class.getName())) {
 
				NdefFormatable ndef = NdefFormatable.get(tag);
				try { 
					if (!ndef.isConnected()) {
						ndef.connect();
					} 
					ndef.format(message);
					showSuccessToast(); 
				} finally { 
					ndef.close();
				} 
			} else if (Arrays.asList(tag.getTechList()).contains(
					Ndef.class.getName())) {

4
CodeRank
This code example shows how to use the following methods: getId, getTechList
	public static int treatAsNewTag(Intent intent, Context context) {
		// Check if Intent has a NFC Tag. 
		if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
			Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
			mTag = tag;
			mUID = tag.getId();
 
			// Show Toast message with UID. 
//			String id = " (UID: "; 
//			id += byte2HexString(tag.getId()); 
//			id += ")"; 
//			Toast.makeText(context, id, Toast.LENGTH_LONG).show(); 
 
			// Return "1" if device supports Mifare Classic. "0" otherwise. 
			return (Arrays.asList(tag.getTechList()).contains(MifareClassic.class.getName())) ? 1 : 0;
		} 
		return -1; 
	} 
 
	/** 
Full Snippet Info
4
CodeRank
Related Android Tag Questions & Answers:
Other Android Tag Examples
23:	
24:			// Creating tags
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
-
23:	
24:			// Creating tags
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
-
24:			// Creating tags
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
-
24:			// Creating tags
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
-
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
29:	
-
25:			Tag tag1 = new Tag("Shopping");
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
29:	
-
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
29:	
30:			// Inserting tags in db
-
26:			Tag tag2 = new Tag("Important");
27:			Tag tag3 = new Tag("Watchlist");
28:			Tag tag4 = new Tag("Androidhive");
29:	
30:			// Inserting tags in db
-
82:	
83:			List<Tag> allTags = db.getAllTags();
84:			for (Tag tag : allTags) {
85:				Log.d("Tag Name", tag.getTagName());
86:			}

Read More

13:			if (c.moveToFirst()) {
14:				do {
15:					Tag t = new Tag();
16:					t.setId(c.getInt((c.getColumnIndex(KEY_ID))));
17:					t.setTagName(c.getString(c.getColumnIndex(KEY_TAG_NAME)));
-
13:			if (c.moveToFirst()) {
14:				do {
15:					Tag t = new Tag();
16:					t.setId(c.getInt((c.getColumnIndex(KEY_ID))));
17:					t.setTagName(c.getString(c.getColumnIndex(KEY_TAG_NAME)));

Read More

1:		 * Creating tag
2:		 */
3:		public long createTag(Tag tag) {
4:			SQLiteDatabase db = this.getWritableDatabase();
5:

Read More

See Code Examples for Android Tag Methods: