当前位置: 首页>>代码示例>>Java>>正文


Java Tag.getId方法代码示例

本文整理汇总了Java中android.nfc.Tag.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Tag.getId方法的具体用法?Java Tag.getId怎么用?Java Tag.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.nfc.Tag的用法示例。


在下文中一共展示了Tag.getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
@Override
    public void onNewIntent(Intent intent) 
    {
	      String action = intent.getAction();
//	    Log.i("!intent! ", action);

	      Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

        byte[] id = tag.getId();
        String serialNumber = bytesToHex(id);
        WritableMap idData = Arguments.createMap();
        idData.putString("id", serialNumber);

        sendEvent(this.reactContext, "NFCCardID", idData);

    }
 
开发者ID:petersobolev,项目名称:nfc-react-native-simple,代码行数:17,代码来源:NfcReactNativeSimpleModule.java

示例2: readTag

import android.nfc.Tag; //导入方法依赖的package包/类
private void readTag(Tag t) {
    byte[] id = t.getId();

    // get NDEF tag details
    Ndef ndefTag = Ndef.get(t);

    // get NDEF message details
    NdefMessage ndefMesg = ndefTag.getCachedNdefMessage();
    if (ndefMesg == null) {
        return;
    }
    NdefRecord[] ndefRecords = ndefMesg.getRecords();
    if (ndefRecords == null) {
        return;
    }
    for (NdefRecord record : ndefRecords) {
        short tnf = record.getTnf();
        String type = new String(record.getType());
        if (tnf == NdefRecord.TNF_WELL_KNOWN && Arrays.equals(type.getBytes(), NdefRecord.RTD_URI)) {
            String url = new String(record.getPayload());
            recordBadge(url);
        }
    }
}
 
开发者ID:The-WebOps-Club,项目名称:saarang-iosched,代码行数:25,代码来源:NfcBadgeActivity.java

示例3: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();

    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

        // Get tag ID and turn into String
        byte[] tagIDbytes = tag.getId();
        tagID = bytesToHex(tagIDbytes);

        if (!tagID.equals("")) {
            // Dismiss the 'Scan NFC Tag' dialog and show the 'Set tag name' dialog
            dismissDialog(DIALOG_READ);

            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

            MainActivity.this.showDialog(DIALOG_SET_TAGNAME);
        }
    }
}
 
开发者ID:adrianchifor,项目名称:TapUnlock,代码行数:22,代码来源:MainActivity.java

示例4: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
@Override
protected void onNewIntent( Intent intent ) {
    // NDEF exchange mode
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        byte[] idBytes = null;
        if (tag != null) {
            idBytes = tag.getId();
        } else {
            idBytes = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
        }
        String msg = getString(R.string.unable_to_read_tag_id);
        if (idBytes != null) {
            lastReadNfcMessage = Utilities.getHexString(idBytes, -1);
            msg = lastReadNfcMessage;
        } else {
            lastReadNfcMessage = ""; //$NON-NLS-1$
        }
        readMessageEditText.setText(msg);
    }

}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:23,代码来源:NfcIdReaderActivity.java

示例5: resolveIntent

import android.nfc.Tag; //导入方法依赖的package包/类
void resolveIntent(Intent intent) {
    Log.i("test", "start method");
    // 1) Parse the intent and get the action that triggered this intent
    String action = intent.getAction();
    // 2) Check if it was triggered by a tag discovered interruption.
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
        Log.i("test", "in if");
        //  3) Get an instance of the TAG from the NfcAdapter
        Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        byte[] id = tagFromIntent.getId();
        try {
            lastDetectUid = getHexString(id);
            // 讀到tag即自動填寫uid欄位
            if(dialogRecordUid != null && dialogRecordUid.isShown()){
                dialogRecordUid.setText(lastDetectUid);
            }else{
                ShowAddNewDialog();
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }// End of method
    else {
        Log.i("Error", action);
    }
    Log.i("test", "end method");
}
 
开发者ID:qwe321qwe321qwe321,项目名称:NFC-UID-Emulator,代码行数:28,代码来源:MainActivity.java

示例6: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
public void onNewIntent (Intent intent) {
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    byte[] id = tag.getId();
    ByteBuffer wrapped = ByteBuffer.wrap(id);
    wrapped.order(ByteOrder.LITTLE_ENDIAN);
    int signedInt = wrapped.getInt();
    long number = signedInt & 0xfffffff1;
    Evt(number);
}
 
开发者ID:ThibaudCrespin,项目名称:iBeaconReader,代码行数:10,代码来源:MainActivity.java

示例7: readTagFromIntent

import android.nfc.Tag; //导入方法依赖的package包/类
/**
 * Reads a tag for a given intent and notifies listeners
 * @param intent
 */
private void readTagFromIntent(Intent intent) {
	Log.d(LOG_TAG, "readTagFromIntent: ");
	
	String action = intent.getAction();

	if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) ||
			NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {

		Log.d(LOG_TAG, "Tag read");

		Tag myTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
		byte[] tagByteId = myTag.getId();

		String tagId = byteArrayToHexString(tagByteId);

		onTagReadListener.onTagRead(tagId);


		// Read the information on the tag
		/*
		Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
		if (rawMsgs != null) {
			NdefRecord[] records = ((NdefMessage) rawMsgs[0]).getRecords();
			String text = ndefRecordToString(records[0]);
			onTagReadListener.onTagRead(text);
		}
		*/

	}
}
 
开发者ID:RowanACM,项目名称:RFID-Attendance,代码行数:35,代码来源:NfcManager.java

示例8: checkAndTrigger

import android.nfc.Tag; //导入方法依赖的package包/类
void checkAndTrigger(final Tag tag) {
    byte[] tag_id = tag.getId();
    if (Arrays.equals(tag_id, data.id)) {
        if (type == is)
            changeSatisfiedState(true);
        else
            changeSatisfiedState(false);
    } else {
        if (type == is)
            changeSatisfiedState(false);
        else
            changeSatisfiedState(true);
    }
}
 
开发者ID:renyuneyun,项目名称:Easer,代码行数:15,代码来源:NfcTagSlot.java

示例9: resolveIntent

import android.nfc.Tag; //导入方法依赖的package包/类
private void resolveIntent(Intent intent) {
    String action = intent.getAction();
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)
            || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)
            || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        Logger.d("NFC Tag detected");
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        byte[] tag_id = tag.getId();
        Intent return_intent = new Intent();
        return_intent.putExtra(EXTRA_ID, tag_id);
        setResult(RESULT_OK, return_intent);
        Logger.v("result handed. finishing self");
        finish();
    }
}
 
开发者ID:renyuneyun,项目名称:Easer,代码行数:16,代码来源:WaitForNfcActivity.java

示例10: handleIntent

import android.nfc.Tag; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
    String action = intent.getAction();
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) ||
            NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        byte[] id = tag.getId();
        writeRandomBytes(Arrays.copyOfRange(id, 1, id.length));

        tagIdView.setText(Hextools.bytesToHex(Arrays.copyOfRange(id, 1, id.length)));
        int randomNumber = ((id[1] + 128) << 16) + ((id[2] + 128) << 8) + (id[3] + 128);
        ImageView die = (ImageView) findViewById(R.id.imageViewDie);
        switch (randomNumber % 6) {
            case 0:
                die.setImageResource(R.drawable.d1);
                break;
            case 1:
                die.setImageResource(R.drawable.d2);
                break;
            case 2:
                die.setImageResource(R.drawable.d3);
                break;
            case 3:
                die.setImageResource(R.drawable.d4);
                break;
            case 4:
                die.setImageResource(R.drawable.d5);
                break;
            case 5:
                die.setImageResource(R.drawable.d6);
                break;
            default:
                die.setImageResource(0);
                break;
        }
    }
}
 
开发者ID:pinae,项目名称:NfcDie,代码行数:37,代码来源:MainActivity.java

示例11: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
public String onNewIntent(Intent intent) {
	String action = intent.getAction();
	if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { 
           Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); 
           byte[] idData = tag.getId();
           
           StringBuffer hexString = new StringBuffer();
           for (int i = 0; i < idData.length; i++) {
           	String byteString = Integer.toHexString(0xFF & idData[i]);
               hexString.append((byteString.length() == 1 ? "0" : "")).append(byteString);
           }
           return hexString.toString().toUpperCase(Locale.GERMAN);
       }
	return null;
}
 
开发者ID:protyposis,项目名称:Studentenportal,代码行数:16,代码来源:NfcLogin.java

示例12: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
	super.onNewIntent(intent);
	Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
	if (tag != null) {
		byte[] tagId = tag.getId();
		String str_tag = toHexString(tagId);

		int loop = str_NfcTagId.size();
		int i;
		for (i = 0; i < loop; i++) {
			if (str_NfcTagId.get(i).equals(str_tag)) {
				break;
			}
		}
		if (i == loop) {
			Toast.makeText(getBaseContext(), "Taging", Toast.LENGTH_LONG)
					.show();
			str_tvNfcTagId += str_tag + "\n";
			str_NfcTagId.add(str_tag);
		} else {
			Toast.makeText(getBaseContext(), "Already Taging",
					Toast.LENGTH_LONG).show();
		}

		tv_newTagId.setText(str_tvNfcTagId);
	}
}
 
开发者ID:imsukmin,项目名称:SmartExhibition,代码行数:29,代码来源:ManagerActivity.java

示例13: onNewIntent

import android.nfc.Tag; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
	super.onNewIntent(intent);
	Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
	if (tag != null) {
		byte[] tagId = tag.getId();
		String str_tag = toHexString(tagId);
		int loop = alExhibition.size();
		for (int i = 0; i < loop; i++) {
			// get Exhibition that position is i
			Exhibition eh = alExhibition.get(i);
			for (String str : eh.getNfcTagId())
				if (str.equals(str_tag)) {
					// Ranking count increase
					PushWebServer pws = new PushWebServer();
					String androidId = ExhibitionDataManager.getInstance()
							.getAndroidId();
					String calendar = makeCalendarString();
					String pushMsg = String.format(
							"checkHitCount?index=%d&userID=%s&time=%s",
							eh.getIndex(), androidId, calendar);
					pws.setPushMsg(pushMsg);
					pws.start();
					// Intent
					Intent mIntent = new Intent(
							ExhibitionListActivity.this,
							ExhibitionActivity.class);
					// put Extra selectNum
					mIntent.putExtra("selectNum", i);
					startActivity(mIntent);
					break;
				}
		}
	}
}
 
开发者ID:imsukmin,项目名称:SmartExhibition,代码行数:36,代码来源:ExhibitionListActivity.java

示例14: showTagId

import android.nfc.Tag; //导入方法依赖的package包/类
private void showTagId(Tag tag) {
    byte[] id = tag.getId();
    mCardInfo.setText(toHex(id));
}
 
开发者ID:rainhard,项目名称:wNFCard,代码行数:5,代码来源:NewCardActivity.java

示例15: NfcIso15693

import android.nfc.Tag; //导入方法依赖的package包/类
public NfcIso15693(Tag tag) {
    nfcv = NfcV.get(tag);
    uid = tag.getId();
    maxTranscieveLength = nfcv.getMaxTransceiveLength();
}
 
开发者ID:SMARTRACTECHNOLOGY-PUBLIC,项目名称:smartrac-sdk-java-android-nfc,代码行数:6,代码来源:NfcIso15693.java


注:本文中的android.nfc.Tag.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。