Merge "docs: Revised "activity launched with NFC intent" code sample to demonstrate using onNewIntent() in these situations" into nyc-dev
diff --git a/docs/html/guide/topics/connectivity/nfc/nfc.jd b/docs/html/guide/topics/connectivity/nfc/nfc.jd
index 520f520..881a75f 100644
--- a/docs/html/guide/topics/connectivity/nfc/nfc.jd
+++ b/docs/html/guide/topics/connectivity/nfc/nfc.jd
@@ -487,19 +487,22 @@
intent and gets the NDEF messages from an intent extra.</p>
<pre>
-public void onResume() {
- super.onResume();
+@Override
+protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
...
- if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
- Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
- if (rawMsgs != null) {
- msgs = new NdefMessage[rawMsgs.length];
- for (int i = 0; i < rawMsgs.length; i++) {
- msgs[i] = (NdefMessage) rawMsgs[i];
+ if (intent != null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
+ Parcelable[] rawMessages =
+ intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
+ if (rawMessages != null) {
+ NdefMessage[] messages = new NdefMessage[rawMessages.length];
+ for (int i = 0; i < rawMessages.length; i++) {
+ messages[i] = (NdefMessage) rawMessages[i];
}
+ // Process the messages array.
+ ...
}
}
- //process the msgs array
}
</pre>