本文整理汇总了Java中ch.uzh.csg.nfclib.NfcLibException类的典型用法代码示例。如果您正苦于以下问题:Java NfcLibException类的具体用法?Java NfcLibException怎么用?Java NfcLibException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NfcLibException类属于ch.uzh.csg.nfclib包,在下文中一共展示了NfcLibException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPayment
import ch.uzh.csg.nfclib.NfcLibException; //导入依赖的package包/类
private void initPayment(NfcInitiator nfcTransceiver) throws NfcLibException {
INfcEventHandler nfcEventHandler;
if (this.paymentType == PaymentType.REQUEST_PAYMENT)
nfcEventHandler = nfcEventHandlerRequest;
else
nfcEventHandler = nfcEventHandlerSend;
if (nfcTransceiver != null) {
this.nfcTransceiver = nfcTransceiver;
} else {
this.nfcTransceiver = new NfcInitiator(nfcEventHandler, activity, userInfos.getUserId());
if (Config.DEBUG)
Log.d(TAG, "Init and enable transceiver");
this.nfcTransceiver.enable(activity);
}
}
示例2: turnOn
import ch.uzh.csg.nfclib.NfcLibException; //导入依赖的package包/类
@Override
public void turnOn(Activity activity) throws NfcLibException {
nfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(activity);
if (nfcAdapter == null) {
throw new NfcLibException("NFC Adapter is null");
}
if (!nfcAdapter.isEnabled()) {
throw new NfcLibException("NFC is not enabled");
}
/*
* Based on the reported issue in
* https://code.google.com/p/android/issues/detail?id=58773, there is a
* failure in the Android NFC protocol. The IsoDep might transceive a
* READ BINARY, if the communication with the tag (or HCE) has been idle
* for a given time (125ms as mentioned on the issue report). This idle
* time can be changed with the EXTRA_READER_PRESENCE_CHECK_DELAY
* option.
*/
Bundle options = new Bundle();
//this causes a huge delay for a second reconnect! don't use this!
//options.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 5000);
nfcAdapter.enableReaderMode(activity, this, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, options);
}
示例3: turnOn
import ch.uzh.csg.nfclib.NfcLibException; //导入依赖的package包/类
@Override
public void turnOn(Activity activity) throws NfcLibException {
UsbManager manager = (UsbManager) activity.getSystemService(Context.USB_SERVICE);
reader = new Reader(manager);
UsbDevice externalDevice = externalReaderAttached(activity);
if (externalDevice == null) {
throw new NfcLibException("External device is not set");
}
PendingIntent permissionIntent = PendingIntent.getBroadcast(activity, 0, new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
broadcastReceiver = createBroadcastReceiver(reader, eventHandler);
activity.registerReceiver(broadcastReceiver, filter);
manager.requestPermission(externalDevice, permissionIntent);
setOnStateChangedListener();
}
示例4: PaymentRequestInitializer
import ch.uzh.csg.nfclib.NfcLibException; //导入依赖的package包/类
protected PaymentRequestInitializer(Activity activity, NfcInitiator nfcTransceiver, IPaymentEventHandler paymentEventHandler, UserInfos userInfos, PaymentInfos paymentInfos, ServerInfos serverInfos, IPersistencyHandler persistencyHandler, PaymentType type) throws IllegalArgumentException, NfcLibException {
checkParameters(activity, paymentEventHandler, userInfos, paymentInfos, serverInfos, persistencyHandler, type);
this.paymentType = type;
this.activity = activity;
this.paymentEventHandler = paymentEventHandler;
this.userInfos = userInfos;
this.serverInfos = serverInfos;
this.paymentInfos = paymentInfos;
this.persistencyHandler = persistencyHandler;
this.executorService = Executors.newSingleThreadExecutor();
initPayment(nfcTransceiver);
}
示例5: turnOn
import ch.uzh.csg.nfclib.NfcLibException; //导入依赖的package包/类
/**
* Turns on the NFC controller, i.e., binds the NFC controller to the given
* activity.
*
* @throws NfcLibException
*/
public void turnOn(Activity activity) throws NfcLibException;