Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d054dc72 authored by Kevin Hufnagle's avatar Kevin Hufnagle Committed by android-build-merger
Browse files

docs: Revised "activity launched with NFC intent" code sample to demonstrate...

docs: Revised "activity launched with NFC intent" code sample to demonstrate using onNewIntent() in these situations am: bd66ef7f am: 69e48724
am: 8d2500d5

Change-Id: Ic7fc0211d298a5012265aa5faab9b318092c1828
parents 72b223c5 8d2500d5
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -487,19 +487,22 @@ intent. The following example checks for the {@link android.nfc.NfcAdapter#ACTIO
intent and gets the NDEF messages from an intent extra.</p>
intent and gets the NDEF messages from an intent extra.</p>


<pre>
<pre>
public void onResume() {
&#64;Override
    super.onResume();
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    ...
    ...
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
    if (intent != null &amp;&amp; NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        Parcelable[] rawMessages =
        if (rawMsgs != null) {
            intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            msgs = new NdefMessage[rawMsgs.length];
        if (rawMessages != null) {
            for (int i = 0; i &lt; rawMsgs.length; i++) {
            NdefMessage[] messages = new NdefMessage[rawMessages.length];
                msgs[i] = (NdefMessage) rawMsgs[i];
            for (int i = 0; i < rawMessages.length; i++) {
                messages[i] = (NdefMessage) rawMessages[i];
            }
            }
            // Process the messages array.
            ...
        }
        }
    }
    }
    //process the msgs array
}
}
</pre>
</pre>