本文整理汇总了Java中android.nfc.tech.MifareClassic.connect方法的典型用法代码示例。如果您正苦于以下问题:Java MifareClassic.connect方法的具体用法?Java MifareClassic.connect怎么用?Java MifareClassic.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.nfc.tech.MifareClassic
的用法示例。
在下文中一共展示了MifareClassic.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveIntent
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
void resolveIntent(Intent intent) {
// 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_TECH_DISCOVERED.equals(action)) {
// 3) Get an instance of the TAG from the NfcAdapter
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
// 4) Get an instance of the Mifare classic card from this TAG
// intent
MifareClassic mfc = MifareClassic.get(tagFromIntent);
try {
mfc.connect();
mRKFCard = new RKFCard(mfc);
mCardContents = mRKFCard.readEntireCard();
txtRaw.setText(DataType.getHexString(mCardContents));
} catch (IOException e1) {
Log.e(TAG, e1.getLocalizedMessage(), e1);
}
Toast t = Toast.makeText(this, "Dump done!", Toast.LENGTH_SHORT);
t.show();
}
}
示例2: MifareMad
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
public MifareMad(MifareClassic card) throws IOException {
this.card = card;
if(!card.isConnected()) {
try {
card.connect();
readMad();
} finally {
card.close();
}
} else {
readMad();
}
}