本文整理汇总了Java中android.nfc.tech.MifareClassic.get方法的典型用法代码示例。如果您正苦于以下问题:Java MifareClassic.get方法的具体用法?Java MifareClassic.get怎么用?Java MifareClassic.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.nfc.tech.MifareClassic
的用法示例。
在下文中一共展示了MifareClassic.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
protected Pair<ReadCardResult, Wallet> doInBackground(Tag... tags) {
MifareClassic card = null;
try {
card = MifareClassic.get(tags[0]);
} catch (NullPointerException e) {
/* Error while reading card. This problem occurs on HTC devices from the ONE series with Android Lollipop (status of June 2015)
* Try to repair the tag.
*/
card = MifareClassic.get(MifareUtils.repairTag(tags[0]));
}
if(card == null)
return new Pair<ReadCardResult, Wallet>(null, null);
final Wallet wallet = new Wallet(card);
final ReadCardResult result = wallet.readCard();
return new Pair<ReadCardResult, Wallet>(result, wallet);
}
示例2: 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();
}
}
示例3: onResume
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
if(oldIntent != getIntent()) {
if(NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) {
Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
mfc = null;
if(tag != null) {
mfc = MifareClassic.get(tag);
}
debugString = "";
if(null != mfc) {
readCard();
}
}
}
oldIntent = getIntent();
}
示例4: tagDetected
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
private void tagDetected(Tag tag) {
MifareClassic mifareTag = MifareClassic.get(tag);
if (mifareTag == null) {
Toast.makeText(this, getString(R.string.err_unknown_card_type), Toast.LENGTH_SHORT).show();
return;
}
if (!mState.hasKeys()) {
Toast.makeText(this, R.string.tag_no_keys, Toast.LENGTH_SHORT).show();
} else if (mState.getState() == DomainState.State.CLEAN) {
Toast.makeText(this, R.string.tag_not_recording, Toast.LENGTH_SHORT).show();
} else if (mState.getState() == DomainState.State.LOADED) {
Toast.makeText(this, R.string.tag_not_replaying, Toast.LENGTH_SHORT).show();
} else if (mState.getState() == DomainState.State.RECORDING) {
readTag(mifareTag);
} else if (mState.getState() == DomainState.State.REPLAYING) {
writeTag(mifareTag);
}
}
示例5: runMifareTest
import android.nfc.tech.MifareClassic; //导入方法依赖的package包/类
private void runMifareTest(Tag tag) {
MifareClassic mf = MifareClassic.get(tag);
mMifareTest = new MifareTest(mf, this, MAIN_Log);
mMifareTest.execute();
dismissDialog(DIALOG_MF_WAIT_FOR_TAG);
showDialog(DIALOG_MF_WAIT_FOR_FINISH);
}