问题描述
我希望我的Android应用程序进行扫描NFC标签之后开始,所以要通过添加以下行一些测试我修改Favebooks的tiapp.xml(钛一个简单的教程应用程序):
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>
不幸的是,另一个应用程序名为NFC服务,它看起来酷似Favebooks,开始扫描标签后,而不是它。我曾尝试使用无济于事每launchMode。我究竟做错了什么?
修改
为简单起见,我们把这个index.js。
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:
[信息]:TiRootActivity:(主)[0,0]检查站,对根系活力的简历。活性= com.Test.app.TestActivity@42a0df48
[信息]:启动意图
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.Test.app.TestActivity@42a0df48[INFO] : Launch Intent https://test.com
位,如果我们preSS主页按钮,点击应用程序图标,去检查我们的记录,我们可以比刚开始有什么不同的活动ID看到。所以,我们已经写在文本字段中迷路了,例如什么。我不希望这种情况发生。
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.
[信息]:TiRootActivity:(主)[0,0]检查站,对根系活力创造,savedInstanceState:空
[信息]:启动意图空
[信息]:TiRootActivity:(主)[0,0]检查站,对根系活力的简历。活动= com.Test.app.TestActivity@42cb8370
[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
推荐答案
我也有类似的问题,我已经了解,原因是Android的:FavebooksActivityNAME =,如果我删除了活动的名称,有没有一个替代的应用程序。我希望这可以帮助你。
I had a similar problem and I have understood that the cause was android:name=".FavebooksActivity", if I deleted the name of activity, there was not a replacing of the app. I hope this can help you.
这篇关于应用程序称为QUOT; NFC服务]更换自己的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!