NfcAdapter.EnableForegroundDispatch 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
启用对给定活动的前台调度。
[Android.Runtime.Register("enableForegroundDispatch", "(Landroid/app/Activity;Landroid/app/PendingIntent;[Landroid/content/IntentFilter;[[Ljava/lang/String;)V", "")]
public void EnableForegroundDispatch(Android.App.Activity? activity, Android.App.PendingIntent? intent, Android.Content.IntentFilter[]? filters, string[][]? techLists);
[<Android.Runtime.Register("enableForegroundDispatch", "(Landroid/app/Activity;Landroid/app/PendingIntent;[Landroid/content/IntentFilter;[[Ljava/lang/String;)V", "")>]
member this.EnableForegroundDispatch : Android.App.Activity * Android.App.PendingIntent * Android.Content.IntentFilter[] * string[][] -> unit
参数
- activity
- Activity
要调度到的活动
- intent
- PendingIntent
要为调度启动的 PendingIntent
- filters
- IntentFilter[]
要替代其调度的 IntentFilters,或始终调度为 null
- techLists
- String[][]
用于执行意向调度 NfcAdapter#ACTION_TECH_DISCOVERED 匹配的技术列表
- 特性
例外
如果活动当前不在前台,则为
注解
启用对给定活动的前台调度。
当将发现 Tag 的应用程序调度时,这将优先于前台活动。
如果向此方法提供任何 IntentFilters,则它们用于匹配 NfcAdapter#ACTION_NDEF_DISCOVERED 和 . NfcAdapter#ACTION_TAG_DISCOVERED. 由于 NfcAdapter#ACTION_TECH_DISCOVERED 依赖该调度意向的 IntentFilter 匹配之外的元数据是通过单独传入技术列表来处理的。 技术列表中的每个第一级条目都表示一系列必须存在才能匹配的技术。 如果第一级集中的任何一个匹配,则调度将通过给定的 PendingIntent 路由。 换句话说,第二个级别是一起 AND 的,第一个级别条目是 ORed 在一起。
如果同时filters传递null用于执行通配符的参数,techLists并将导致前台活动通过NfcAdapter#ACTION_TAG_DISCOVERED意向接收所有标记。
此方法必须从主线程调用,并且仅在活动处于前台(恢复)时才调用。 此外,活动必须在回调完成Activity#onPause之前调用#disableForegroundDispatch,以在启用前台调度后禁用前台调度。
需要 android.Manifest.permission#NFC 权限。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。