I want my Android app to start after scanning an NFC tag, so to make some tests I modified the tiapp.xml of Favebooks (a simple tutorial app for Titanium) by adding the following lines:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-sdk android:minSdkVersion="14"/>
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<application android:theme="@style/Theme.Titanium">
<activity
android:configChanges="keyboardHidden|orientation"
android:label="Favebooks"
android:launchMode="singleTop"
android:name=".FavebooksActivity" android:screenOrientation="portrait">
<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.NDEF_DISCOVERED"/>
<data android:host="test.it" android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
</android>
Unfortunately, another APP called "Nfc service", which looks exactly like Favebooks, starts instead of it after scanning a tag. I have tried every launchMode available to no avail. What am I doing wrong? Here's a screenshot.
EDIT
For simplicity's sake, let's put this in index.js.
Ti.API.info('Launch Intent ' + Ti.App.Android.launchIntent.getData());
var win = Ti.UI.createWindow({
layout : 'vertical',
height : 'auto'
});
var text = Ti.UI.createTextField({
name : 'test',
hintText : 'test'
});
win.add(text);
win.open();
Now let's try start the app by approaching our device to a tag. It does so correctly:
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.Test.app.TestActivity@42a0df48 [INFO] : Launch Intent https://test.com
Bit if we press the home button, click on the app icon and go check our logs we can see than the activity id of what just started is different. So for example anything that we had written in the text field got lost. I don't want this to happen.
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null [INFO] : Launch Intent null [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.Test.app.TestActivity@42cb8370