Page 371 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 371
}
/************************************
* 여기서부턴 NFC 관련 메소드
************************************/
public void onResume() {
super.onResume();
if (mAdapter != null) {
mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters,
mTechLists);
}
}
public void onPause() {
super.onPause();
if (mAdapter != null) {
mAdapter.disableForegroundDispatch(this);
}
}
// NFC 태그 스캔시 호출되는 메소드
public void onNewIntent(Intent passedIntent) {
// NFC 태그
Tag tag = passedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag != null) {
byte[] tagId = tag.getId();
readResult.append("태그ID : " + toHexString(tagId) + "\n"); // TextView에태그ID
덧붙임
}
if (passedIntent != null) {
processTag(passedIntent); // processTag 메소드 호출
}
}
// NFC 태그ID를 리턴하는 메소드
public static final String CHARS = "0123456789ABCDEF";
public static String toHexString(byte[] data) {
- 364 -