Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created November 9, 2017 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/869a5ffd4f2934f9bca0253d27bda19d to your computer and use it in GitHub Desktop.
Save ssaurel/869a5ffd4f2934f9bca0253d27bda19d to your computer and use it in GitHub Desktop.
onCreate method for the NFC Reader Tutorial
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.text);
nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (nfcAdapter == null) {
Toast.makeText(this, "No NFC", Toast.LENGTH_SHORT).show();
finish();
return;
}
pendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, this.getClass())
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment