当前位置: 首页>>代码示例>>Java>>正文


Java NfcLibException类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:jetonmemeti,项目名称:android-nfc-payment-library,代码行数:19,代码来源:PaymentRequestInitializer.java

示例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);
}
 
开发者ID:jetonmemeti,项目名称:android-kitkat-nfc-library,代码行数:27,代码来源:InternalNfcTransceiver.java

示例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();
}
 
开发者ID:jetonmemeti,项目名称:android-kitkat-nfc-library,代码行数:21,代码来源:ExternalNfcTransceiver.java

示例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);
}
 
开发者ID:jetonmemeti,项目名称:android-nfc-payment-library,代码行数:16,代码来源:PaymentRequestInitializer.java

示例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;
 
开发者ID:jetonmemeti,项目名称:android-kitkat-nfc-library,代码行数:8,代码来源:INfcTransceiver.java


注:本文中的ch.uzh.csg.nfclib.NfcLibException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。