I'm writing the Static Handover Select Record on a Tag with the Wifi Protected Setup Configuration as specified in the NFC Forum. (SSID, Encryption, ...).
The type is application/vnd.wfa.wsc
Additionally I add the Android Application Record as last NDEF Record into my NDEF Message.
I also have a filter defined in my Android Manifest XML for NFC Tags discovered.
The problem is: If the application is launched and the Reader Activity is shown, I can read the tag and everything works fine.
Now I want the following: If I scan my Tag, and the activity isn't @ foreground or not launched, the app should start itself and switch automatically into the reader mode.
- If I do that, the Nexus 4 doesn't launch by the AAR... It just starts, if i put this Record on the first place of the NDEF Message, but then I loose the event for the Ndef/Tech/Tag discovered.
- I also have the filter in my android manififest, but this seems not to do anything, I tried all three events but nothing happens
Also, if the Tag is scanned, normally if more applications are filtering for the event, I get a app-selector, which app I want to start for this Tag. But my application is not listed here.
This is how I create the message:
new NdefMessage(new NdefRecord[] { Utils.createHandoverSelectRecord(ac_record.toByteArray()), wpsRecord, aarRecord });
And here is the filter in my android manifest:
<activity android:name=".activities.NFCWriterActivity"></activity>
<activity android:name=".activities.NFCReaderActivity" android:exported="true" android:permission="android.permission.NFC">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".activities.NFCBeamActivity"></activity>
<activity android:name=".activities.WifiManagerActivity"></activity>
<activity android:name=".activities.WifiConfiguratorActivity"></activity>
<activity android:name=".activities.TagWriterOptionsActivity"></activity>
<activity android:name=".activities.WifiScannerTagActivity"></activity>
<activity android:name=".activities.WifiScannerActivity"></activity>
<activity android:name=".activities.WifiListActivity"></activity>
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<!-- <data android:mimeType="application/vnd.wfa.wsc" /> -->
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
I don't really know where I should filter, I thought it would be enough to filter in the Reader Activity, but this didn't work, so I added the filters also in the MainActivity, but this also does nothing.
I hope you can help me.
Thanks!