Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created November 9, 2017 13:50
Show Gist options
  • Save ssaurel/a95613fb8b9342400ddb6508aaa5aa98 to your computer and use it in GitHub Desktop.
Save ssaurel/a95613fb8b9342400ddb6508aaa5aa98 to your computer and use it in GitHub Desktop.
onResume method for the NFC Reader tutorial
@Override
protected void onResume() {
super.onResume();
if (nfcAdapter != null) {
if (!nfcAdapter.isEnabled())
showWirelessSettings();
nfcAdapter.enableForegroundDispatch(this, pendingIntent, null, null);
}
}
private void showWirelessSettings() {
Toast.makeText(this, "You need to enable NFC", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment