本文整理汇总了Java中android.nfc.tech.IsoDep.get方法的典型用法代码示例。如果您正苦于以下问题:Java IsoDep.get方法的具体用法?Java IsoDep.get怎么用?Java IsoDep.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.nfc.tech.IsoDep
的用法示例。
在下文中一共展示了IsoDep.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(final Tag tag) {
Log.d(TAG, "Tag found: " + tag.toString());
Log.d(TAG, "Id: " + HexStrings.toHexString(tag.getId()));
for (String tech: tag.getTechList()) {
Log.d(TAG, "Tech: " + tech);
}
if (Arrays.asList(tag.getTechList()).contains("android.nfc.tech.IsoDep")) {
IsoDepApduInterface apduInterface;
try {
apduInterface = new IsoDepApduInterface(IsoDep.get(tag));
} catch (IOException e) {
fail(e.getMessage());
e.printStackTrace();
return;
}
dispatchLoadTask(apduInterface);
}
}
示例2: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
Log.d(TAG, "onTagDiscovered: " + tag);
final long startTime = System.currentTimeMillis();
long duration;
try {
IsoDep isoDep = IsoDep.get(tag);
isoDep.connect();
onTagDiscovered(tag, isoDep, true);
} catch (Throwable e) {
Log.e(TAG, "Exception in onTagDiscovered", e);
getPaymentRequestDelegate().onPaymentError(e.getMessage());
}
}
示例3: create
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/**
* Creates a transceiver for the specified tag.
* @return null is returned if a transceiver could not be created
*/
public static Transceiver create(Logger logger, Tag tag)
{
IsoDep isoDep = IsoDep.get(tag);
if (null == isoDep)
{
logger.warn(TAG, "Unable to create IsoDep for NFC tag: " + StringUtil.join(tag.getTechList(), ", "));
return null;
}
logger.info(TAG, "Connnecting to ISO-DEP: " + isoDep.isConnected());
try
{
isoDep.connect();
isoDep.setTimeout(30000);
return new Transceiver(logger, isoDep);
}
catch (Exception ex)
{
logger.error(TAG, "Unable to connect to ISO-DEP", ex);
return null;
}
}
示例4: get
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
public static AndroidCard get(Tag tag) throws IOException {
IsoDep card = IsoDep.get(tag);
if(card != null) {
/* Workaround for the Samsung Galaxy S5 (since the
* first connection always hangs on transceive).
* TODO: This could be improved if we could identify
* Samsung Galaxy S5 devices
*/
card.connect();
card.close();
return new AndroidCard(card);
} else {
return null;
}
}
示例5: doInBackground
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
protected String doInBackground(Tag... params) {
Tag tag = params[0];
tagCommunicator = IsoDep.get(tag);
try {
tagCommunicator.connect();
tagCommunicator.setTimeout(5000);
if (tagCommunicator.isConnected()) {
readCard();
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例6: get
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
public static AndroidCard get(Tag tag) throws IOException {
IsoDep card = IsoDep.get(tag);
/* Workaround for the Samsung Galaxy S5 (since the
* first connection always hangs on transceive).
* TODO: This could be improved if we could identify
* Samsung Galaxy S5 devices
*/
card.connect();
card.close();
if(card != null) {
return new AndroidCard(card);
} else {
return null;
}
}
示例7: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
doTapFeedback();
clearImage();
// maybe clear console or show separator, depends on settings
if (mAutoClear) {
clearMessages();
} else {
addMessageSeparator();
}
// get IsoDep handle and run xcvr thread
IsoDep isoDep = IsoDep.get(tag);
if (isoDep == null) {
onError(getString(R.string.wrong_tag_err));
} else {
ReaderXcvr xcvr = new PaymentReaderXcvr(isoDep, "", this, TEST_MODE_EMV_READ);
new Thread(xcvr).start();
}
}
示例8: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
doTapFeedback();
clearImage();
// maybe clear console or show separator, depends on settings
if (mAutoClear) {
clearMessages();
} else {
// two separators between taps/discoveries
addMessageSeparator();
addMessageSeparator();
}
// get IsoDep handle and run xcvr thread
IsoDep isoDep = IsoDep.get(tag);
if (isoDep == null) {
onError(getString(R.string.wrong_tag_err));
} else {
List<SmartcardApp> memberApps = mGrpToMembersMap.get(mSelectedGrpPos);
new Thread(new BatchReaderXcvr(isoDep, memberApps, this)).start();
}
}
示例9: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
if (Config.DEBUG)
Log.d(TAG, "tag discovered: " + tag);
if (!enabled) {
if (Config.DEBUG)
Log.d(TAG, "tag discovered, but InternalNfcTransceiver not enabled");
return;
}
isoDep = IsoDep.get(tag);
try {
isoDep.connect();
nfcInit.tagDiscovered();
} catch (IOException e) {
if (Config.DEBUG)
Log.e(TAG, "Could not connnect isodep: ", e);
eventHandler.handleMessage(NfcEvent.INIT_FAILED, null);
}
}
示例10: send
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/**
* Send message via a Nfc connection.
*
* @param message The message in byte array form
* @return The response from {@link NfcServerSocket}. null might be returned
* if <li>the connection is lost. <li> {@link NfcServerSocket} does
* not return response within timeout. <li> {@link NfcServerSocket}
* returns a null response.
*/
public byte[] send(byte[] message) {
if (currentTag == null) {
return null;
}
if (isoDep == null) {
isoDep = IsoDep.get(currentTag);
}
if (isoDep.isConnected()) {
try {
byte[] response = isoDep.transceive(message);
return response;
} catch (IOException e) {
e.printStackTrace();
return null;
}
} else {
log("isodep not connected");
return null;
}
}
示例11: onNewIntent
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/**
*
*/
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "onNewIntent Called");
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
// validate that this tag can be written....
myStatusTextView.setText("tag detected");
pbCircular.setVisibility(View.VISIBLE);
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
Log.d(TAG, detectedTag.toString());
Log.d(TAG, detectedTag.getTechList().toString());
this.isoDep = IsoDep.get(detectedTag);
// Have the background task send the image
fileSender.execute(imageBuffer);
fileSender = new SendFileToWISP(this);
}// end if
}
示例12: onNewIntent
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent) {
Log.i(TAG, "Discovered tag with intent: " + intent);
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
isotag = IsoDep.get(tag);
if (isotag != null) {
Log.i(TAG,"Found IsoDep tag!");
// Make sure we're not already communicating with a card
if (activityState == STATE_IDLE) {
askForPin();
}
}
}
}
示例13: openConnection
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/**
* Opens a connection with the ID by doing BAC
* Uses hardcoded parameters for now
*
* @param tag - NFC tag that started this activity (ID NFC tag)
* @return PassportService - passportservice that has an open connection with the ID
*/
public PassportService openConnection(Tag tag, final DocumentData docData) throws CardServiceException {
try {
IsoDep nfc = IsoDep.get(tag);
CardService cs = CardService.getInstance(nfc);
this.ps = new PassportService(cs);
this.ps.open();
// Get the information needed for BAC from the data provided by OCR
this.ps.sendSelectApplet(false);
BACKeySpec bacKey = new BACKeySpec() {
@Override
public String getDocumentNumber() {
return docData.getDocumentNumber();
}
@Override
public String getDateOfBirth() { return docData.getDateOfBirth(); }
@Override
public String getDateOfExpiry() { return docData.getExpiryDate(); }
};
ps.doBAC(bacKey);
return ps;
} catch (CardServiceException ex) {
try {
ps.close();
} catch (Exception ex2) {
ex2.printStackTrace();
}
throw ex;
}
}
示例14: AndroidNfcConnection
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/** Contructor de la clase para la gestión de la conexión por NFC.
* @param tag <code>Tag</code> para obtener el objeto <code>IsoDep</code> y establecer la
* conexión.
* @throws IOException Si falla el establecimiento de la conexión. */
public AndroidNfcConnection(final Tag tag) throws IOException {
if (tag == null) {
throw new IllegalArgumentException("El tag NFC no puede ser nulo"); //$NON-NLS-1$
}
this.mIsoDep = IsoDep.get(tag);
this.mIsoDep.connect();
this.mIsoDep.setTimeout(ISODEP_TIMEOUT);
}
示例15: onTagDiscovered
import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
/**
* Callback when a new tag is discovered by the system.
*
* <p>Communication with the card should take place here.
*
* @param tag Discovered tag
*/
public void onTagDiscovered(Tag tag){
LogUtil.i(TAG, "======= Discovered Tag:" + tag + "==========");
// Android's Host-based Card Emulation (HCE) feature implements the ISO-DEP (ISO 14443-4)
// protocol.
//
// In order to communicate with a device using HCE, the discovered tag should be processed
// using the IsoDep class.
mIsoDep = IsoDep.get(tag);
// Connect to the remote NFC device
try {
mIsoDep.connect();
} catch (IOException e) {
e.printStackTrace();
}
mIsoDep.setTimeout(TIMEOUT);
}