Modules.Nfc.NfcForegroundDispatchFilter
> Modules.Nfc.NfcForegroundDispatchFilter

A filter specifying intent, intent filters and technology lists used to match dispatch intents.

The method is used to give priority to the foreground activity when dispatching a discovered tag to an application. This proxy is used to specify the intent, intent filters, and technology lists used to filter the dispatched intents. This proxy automatically creates the required pending intent and will create an intent for the current activity if one is not provided.

Use the Modules.Nfc.createNfcForegroundDispatchFilter method to create a foreground dispatch filter.

See also: enableForegroundDispatch

Examples

Foreground Dispatch filter

This example creates a dispatch filter used to filter NDEF messages that are of mime type 'text/plain' or URI from 'http://www.appcelerator.com'. Additionally, the filter will match tags with the specified technologies. The dispatch filter is then used when calling the enableForegroundDispatch API of the Modules.Nfc.NfcAdapter proxy.

dispatchFilter = nfc.createNfcForegroundDispatchFilter({
    intentFilters: [
        { action: nfc.ACTION_NDEF_DISCOVERED, mimeType: 'text/plain' },
        { action: nfc.ACTION_NDEF_DISCOVERED, scheme: 'http', host: 'www.appcelerator.com' }
    ],
    techLists: [
        [ "android.nfc.tech.NfcF", "android.nfc.tech.NfcA", "android.nfc.Ndef" ],
        [ "android.nfc.tech.Ndef" ],
        [ "android.nfc.tech.MifareClassic" ],
        [ "android.nfc.tech.NfcA" ]
    ]
});

// All tag scans are received by the activity as a new intent. Each
// scan intent needs to be passed to the nfc adapter for processing.
var act = Ti.Android.currentActivity;
act.addEventListener('newintent', function(e) {
    nfcAdapter.onNewIntent(e.intent);
});

// To enable NFC dispatching only while the application is in the foreground,
// the application must signal the module whenever the application state changes.
act.addEventListener('resume', function(e) {
    nfcAdapter.enableForegroundDispatch(dispatchFilter);
});
act.addEventListener('pause', function(e) {
    nfcAdapter.disableForegroundDispatch();
});
  • 1.0.0
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Modules.Nfc.NfcForegroundDispatchFilter
intent : Titanium.Android.Intent

The intent to start the dispatch when matched.

The intent to start the dispatch when matched.

This optional property allows you to override the default behavior for dispatching the intent. If an intent is not provided (the default behavior), then an intent based on the current activity is automatically created with a flag of FLAG_ACTIVITY_SINGLE_TOP.

Modules.Nfc.NfcForegroundDispatchFilter
intentFilters : NfcIntentFilter[]

The intent filters to override dispatching for, or null to always dispatch.

The intent filters to override dispatching for, or null to always dispatch.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Modules.Nfc.NfcForegroundDispatchFilter
techLists : String[][]

The tech lists used to perform matching for dispatching the ACTION_TECH_DISCOVERED intent.

The tech lists used to perform matching for dispatching the ACTION_TECH_DISCOVERED intent.

Defined By

Methods

Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Modules.Nfc.NfcForegroundDispatchFilter
( ) : Titanium.Android.Intent
Gets the value of the intent property. ...

Gets the value of the intent property.

Returns

Modules.Nfc.NfcForegroundDispatchFilter
( ) : NfcIntentFilter[]
Gets the value of the intentFilters property. ...

Gets the value of the intentFilters property.

Returns

Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Modules.Nfc.NfcForegroundDispatchFilter
( ) : String[][]
Gets the value of the techLists property. ...

Gets the value of the techLists property.

Returns

  • String[][]
Modules.Nfc.NfcForegroundDispatchFilter
( intent )
Sets the value of the intent property. ...

Sets the value of the intent property.

Parameters

Returns

  • void
Modules.Nfc.NfcForegroundDispatchFilter
( intentFilters )
Sets the value of the intentFilters property. ...

Sets the value of the intentFilters property.

Parameters

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Modules.Nfc.NfcForegroundDispatchFilter
( techLists )
Sets the value of the techLists property. ...

Sets the value of the techLists property.

Parameters

  • techLists : Array<Array<String>>

    New value for the property.

Returns

  • void