use of android.nfc.NfcAdapter in project Android-Developers-Samples by johnjohndoe.
the class CardReaderFragment method enableReaderMode.
private void enableReaderMode() {
Log.i(TAG, "Enabling reader mode");
Activity activity = getActivity();
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(activity);
if (nfc != null) {
nfc.enableReaderMode(activity, mLoyaltyCardReader, READER_FLAGS, null);
}
}
use of android.nfc.NfcAdapter in project Android-Developers-Samples by johnjohndoe.
the class CardReaderFragment method disableReaderMode.
private void disableReaderMode() {
Log.i(TAG, "Disabling reader mode");
Activity activity = getActivity();
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(activity);
if (nfc != null) {
nfc.disableReaderMode(activity);
}
}
use of android.nfc.NfcAdapter in project weiciyuan by qii.
the class MainTimeLineParentActivity method initNFC.
private void initNFC() {
NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (mNfcAdapter == null) {
return;
}
mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
String text = (GlobalContext.getInstance().getCurrentAccountName());
NdefMessage msg = new NdefMessage(new NdefRecord[] { createMimeRecord("application/org.qii.weiciyuan.beam", text.getBytes()), NdefRecord.createApplicationRecord(getPackageName()) });
return msg;
}
}, this);
}
use of android.nfc.NfcAdapter in project robolectric by robolectric.
the class ShadowNfcAdapterTest method setNdefPushMesageCallback_shouldUseCallback.
@Test
public void setNdefPushMesageCallback_shouldUseCallback() {
final NfcAdapter.CreateNdefMessageCallback callback = mock(NfcAdapter.CreateNdefMessageCallback.class);
final Activity activity = Robolectric.setupActivity(Activity.class);
final NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
adapter.setNdefPushMessageCallback(callback, activity);
assertThat(shadowOf(adapter).getNdefPushMessageCallback()).isSameAs(callback);
}
use of android.nfc.NfcAdapter in project platform_frameworks_base by android.
the class CardEmulation method recoverService.
void recoverService() {
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
sService = adapter.getCardEmulationService();
}
Aggregations