Android应用程序名称未显示在多任务屏幕中 [英] Android App name is not displayed in the multitasking screen
问题描述
我已经开发了一个简单的NFC应用程序,该应用程序读取并显示NFC标签中存在的数据(NDEF记录).我修改了清单文件,以便每当点击标签时,我的应用程序便会打开.
现在的问题是,当我手动打开应用程序并检查多任务屏幕时,它显示了我的应用程序名称,即NFCReader,但是当标签与设备接触时,当应用程序自身打开时,我的应用程序却被打开了,但是当我检查多任务屏幕,它不显示我的应用名称.而是显示NFC服务.我该怎么做才能克服这个问题?
我假设您已将清单中的活动声明设置为类似以下内容:
<activity
android:name=".packagename.MainActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:theme="@style/AppTheme.Main">
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="domain.com"
android:scheme="http" />
</intent-filter>
</activity>
我认为您的问题的答案是您忘记添加的以下代码行:
android:launchMode="singleTask"
请注意::此答案基于 answer .
希望这会有所帮助!
I've developed a simple NFC application that reads and displays the data(NDEF Records) present in the NFC tag. I modified the Manifest file so that whenever a tag gets tapped, my app gets opened.
Now the problem is when I manually open the app and check the multitasking screen, it displays my app name i.e NFCReader but when the app gets opened itself when a tag comes in contact with the device, my app gets opened but when I check the multitasking screen, it doesn't display my app name. Instead it displays NFC Service. What should I do to overcome this issue?
I assume that you have set your activity declaration, in your manifest, to something like this:
<activity
android:name=".packagename.MainActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:theme="@style/AppTheme.Main">
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="domain.com"
android:scheme="http" />
</intent-filter>
</activity>
I think the answer to your question is the following line of code that you forgot to add:
android:launchMode="singleTask"
I invite you to read about launch modes here and here.
Please note: This answer is based on the use of Reader mode API, otherwise check this answer.
Hope this helps!
这篇关于Android应用程序名称未显示在多任务屏幕中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!