A filter specifying intent, intent filters and technology lists used to match dispatch intents.
The
Use the Modules.Nfc.createNfcForegroundDispatchFilter method to create a foreground dispatch filter.
See also: enableForegroundDispatch
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();
});
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
.
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.
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.
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.
Sets the value of the intent property.
New value for the property.
Sets the value of the intentFilters property.
New value for the property.
Sets the value of the lifecycleContainer property.
New value for the property.
Sets the value of the techLists property.
New value for the property.