Android应用程序名称未显示在多任务屏幕中

编程入门 行业动态 更新时间:2024-10-24 06:26:10
本文介绍了Android应用程序名称未显示在多任务屏幕中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经开发了一个简单的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" android:scheme="http" /> </intent-filter> </activity>

我认为您的问题的答案是您忘记添加的以下代码行: android:launchMode="singleTask"

我邀请您阅读有关启动模式的信息此处和此处. 请注意::此答案基于阅读器模式API ,否则请检查此 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" 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应用程序名称未显示在多任务屏幕中

本文发布于:2023-11-27 03:08:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   屏幕   名称   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!