Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void disableNfcReaderMode() {
}
this.nfcAdapter = null;
this.currentActivity = null;
this.clientCallback = null;
}

/**
Expand Down Expand Up @@ -96,20 +97,14 @@ public NfcStatus detectNfcStatus(Activity activity) {
* @return - status if the NFC is available / enabled / active
*/
public NfcStatus startDiscovery(Activity activity, NfcSmartCardReaderCallback callback) {
this.currentActivity = activity;
this.nfcAdapter = NfcAdapter.getDefaultAdapter(this.currentActivity);

if (this.nfcAdapter == null) {
return NfcStatus.NFC_NOT_SUPPORTED;
}

if (!this.nfcAdapter.isEnabled()) {
return NfcStatus.NFC_NOT_ACTIVE;
}
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
if (adapter == null) return NfcStatus.NFC_NOT_SUPPORTED;
if (!adapter.isEnabled()) return NfcStatus.NFC_NOT_ACTIVE;

this.currentActivity = activity;
this.nfcAdapter = adapter;
this.clientCallback = callback;
this.nfcAdapter.enableReaderMode(
this.currentActivity, this, NfcAdapter.FLAG_READER_NFC_A, null);
adapter.enableReaderMode(activity, this, NfcAdapter.FLAG_READER_NFC_A, null);
return NfcStatus.NFC_ACTIVE;
}

Expand Down