use of android.nfc.NfcManager in project android_packages_apps_Settings by LineageOS.
the class NfcPreferenceController method updateNonIndexableKeys.
@Override
public void updateNonIndexableKeys(List<String> keys) {
final NfcManager manager = (NfcManager) mContext.getSystemService(Context.NFC_SERVICE);
if (manager != null) {
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter == null) {
keys.add(KEY_TOGGLE_NFC);
keys.add(KEY_ANDROID_BEAM_SETTINGS);
}
}
}
use of android.nfc.NfcManager in project android_packages_apps_Settings by omnirom.
the class NfcPreferenceController method updateNonIndexableKeys.
@Override
public void updateNonIndexableKeys(List<String> keys) {
final NfcManager manager = (NfcManager) mContext.getSystemService(Context.NFC_SERVICE);
if (manager != null) {
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter == null) {
keys.add(KEY_TOGGLE_NFC);
keys.add(KEY_ANDROID_BEAM_SETTINGS);
}
}
}
use of android.nfc.NfcManager in project android_packages_apps_Settings by DirtyUnicorns.
the class NfcPreferenceController method updateNonIndexableKeys.
@Override
public void updateNonIndexableKeys(List<String> keys) {
final NfcManager manager = (NfcManager) mContext.getSystemService(Context.NFC_SERVICE);
if (manager != null) {
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter == null) {
keys.add(KEY_TOGGLE_NFC);
keys.add(KEY_ANDROID_BEAM_SETTINGS);
}
}
}
use of android.nfc.NfcManager in project android_packages_apps_Settings by crdroidandroid.
the class ConnectedDeviceDashboardFragmentTest method testSummaryProvider_hasNfc_shouldReturnNfcSummary.
@Test
public void testSummaryProvider_hasNfc_shouldReturnNfcSummary() {
final NfcManager nfcManager = mock(NfcManager.class);
final SummaryLoader summaryLoader = mock(SummaryLoader.class);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(NFC_SERVICE)).thenReturn(nfcManager);
when(nfcManager.getDefaultAdapter()).thenReturn(mock(NfcAdapter.class));
SummaryLoader.SummaryProvider provider = new ConnectedDeviceDashboardFragment.SummaryProvider(mContext, summaryLoader);
provider.setListening(false);
verifyZeroInteractions(summaryLoader);
provider.setListening(true);
verify(mContext).getString(R.string.connected_devices_dashboard_summary);
}
use of android.nfc.NfcManager in project xDrip-plus by jamorham.
the class NFCReaderX method doNFC.
@SuppressLint("NewApi")
public static void doNFC(final Activity context) {
if (!useNFC())
return;
mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
try {
if (mNfcAdapter == null) {
JoH.static_toast_long("Phone has no NFC reader");
// finish();
return;
} else if (!mNfcAdapter.isEnabled()) {
JoH.static_toast_long("NFC is not enabled");
return;
}
} catch (NullPointerException e) {
JoH.static_toast_long("Phone NFC is having problems!");
return;
}
nfc_enabled = true;
NfcManager nfcManager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
if (nfcManager != null) {
mNfcAdapter = nfcManager.getDefaultAdapter();
}
if (mNfcAdapter != null) {
try {
mNfcAdapter.isEnabled();
} catch (NullPointerException e) {
return;
}
// some superstitious code here
try {
mNfcAdapter.isEnabled();
} catch (NullPointerException e) {
return;
}
if ((Build.VERSION.SDK_INT >= 19) && (useReaderMode)) {
try {
mNfcAdapter.disableReaderMode(context);
final Bundle options = new Bundle();
options.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 5000);
mNfcAdapter.enableReaderMode(context, new NfcAdapter.ReaderCallback() {
@Override
public void onTagDiscovered(Tag tag) {
Log.d(TAG, "Reader mode tag discovered");
doTheScan(context, tag, false);
}
}, NfcAdapter.FLAG_READER_NFC_V | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS, options);
} catch (NullPointerException e) {
Log.wtf(TAG, "Null pointer exception from NFC subsystem: " + e.toString());
}
} else {
PendingIntent pi = context.createPendingResult(REQ_CODE_NFC_TAG_FOUND, new Intent(), 0);
if (pi != null) {
try {
mNfcAdapter.enableForegroundDispatch(context, pi, new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) }, new String[][] { new String[] { "android.nfc.tech.NfcV" } });
foreground_enabled = true;
} catch (NullPointerException e) {
//
}
}
}
}
}
Aggregations