本文整理匯總了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);
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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");
}
示例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);
}
示例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);
}
*/
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
}
示例14: showTagId
import android.nfc.Tag; //導入方法依賴的package包/類
private void showTagId(Tag tag) {
byte[] id = tag.getId();
mCardInfo.setText(toHex(id));
}
示例15: NfcIso15693
import android.nfc.Tag; //導入方法依賴的package包/類
public NfcIso15693(Tag tag) {
nfcv = NfcV.get(tag);
uid = tag.getId();
maxTranscieveLength = nfcv.getMaxTransceiveLength();
}