Skip to content

Commit 584afa8

Browse files
jhamAndroid (Google) Code Review
authored andcommitted
Merge "Improve the docs a bit for foreground dispatch." into gingerbread
2 parents be4b39d + 167d9e4 commit 584afa8

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

core/java/android/nfc/NfcAdapter.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,18 +419,29 @@ public boolean disable() {
419419
* <p>This will give give priority to the foreground activity when
420420
* dispatching a discovered {@link Tag} to an application.
421421
*
422-
* <p>Activities must call {@link #disableForegroundDispatch} in
423-
* their {@link Activity#onPause} callback.
422+
* <p>If any IntentFilters are provided to this method they are used to match dispatch Intents
423+
* for both the {@link NfcAdapter#ACTION_NDEF_DISCOVERED} and
424+
* {@link NfcAdapter#ACTION_TAG_DISCOVERED}. Since {@link NfcAdapter#ACTION_TECH_DISCOVERED}
425+
* relies on meta data outside of the IntentFilter matching for that dispatch Intent is handled
426+
* by passing in the tech lists separately. Each first level entry in the tech list represents
427+
* an array of technologies that must all be present to match. If any of the first level sets
428+
* match then the dispatch is routed through the given PendingIntent. In other words, the second
429+
* level is ANDed together and the first level entries are ORed together.
424430
*
425-
* <p>a null set of intent filters will cause the forground activity
426-
* to receive all tags.
431+
* <p>If you pass {@code null} for both the {@code filters} and {@code techLists} parameters
432+
* that acts a wild card and will cause the foreground activity to receive all tags via the
433+
* {@link NfcAdapter#ACTION_TAG_DISCOVERED} intent.
427434
*
428-
* <p>This method must be called from the main thread, and
429-
* only when the activity is in the foreground (resumed). *
435+
* <p>This method must be called from the main thread, and only when the activity is in the
436+
* foreground (resumed). Also, activities must call {@link #disableForegroundDispatch} before
437+
* the completion of their {@link Activity#onPause} callback to disable foreground dispatch
438+
* after it has been enabled.
430439
*
431440
* @param activity the Activity to dispatch to
432441
* @param intent the PendingIntent to start for the dispatch
433442
* @param filters the IntentFilters to override dispatching for, or null to always dispatch
443+
* @param techLists the tech lists used to perform matching for dispatching of the
444+
* {@link NfcAdapter#ACTION_TECH_DISCOVERED} intent
434445
* @throws IllegalStateException if the Activity is not currently in the foreground
435446
*/
436447
public void enableForegroundDispatch(Activity activity, PendingIntent intent,

0 commit comments

Comments
 (0)