Android 应用程序创建两个启动器图标
我已经开发了一段时间的应用程序遇到了一个非常令人困惑的问题。突然,当运行我的应用程序时,我发现启动后立即强制关闭。
经过进一步调查,我在启动器中发现了两个启动器图标。其中之一将恢复应用程序(如果正在运行)或强制关闭(如果未运行)。第二个将正常运行 - 正常启动应用程序并正常恢复。
我很困惑,因为我没有做任何(我能想到的)导致这个问题的事情。我没有更改清单中的任何内容,只是实现了一些新方法来更快地更改应用程序中的颜色。
无论我关闭手机、手动终止应用程序还是卸载/重新安装应用程序,这些问题在我的所有模拟器和设备中都同样存在。简单的 ctrl+z 不起作用。澄清一下 - 我想要的只是返回一个启动器图标来正常启动我的应用程序(根本没有什么特别的事情发生)。
更新:
现在,从任一图标启动时都会立即强制关闭。我确实在清单中的两个活动中找到了代码,显示并将第二行从 .LAUNCHER 更改为 .DEFAULT 确实解决了我原来的问题。但是,我现在总是遇到立即强制关闭的情况...现在在我最初的启动器活动中出现了问题(我可以看到)...我在尝试解决此问题时遇到了很多麻烦(不知道该做什么)做)并且我开始变得非常担心!
更新2:
我发现了我的问题,感谢你们的帮助!实际上,我同时发生了两个独立且不相关的问题。第一 - 我的启动器中有两个图标:因为我有两个活动
I am having a very confusing problem with an application I have been working on for some time. Suddenly, when running my application, I found an immediate force close upon launch.
Upon further investigation, I found two launcher icons in my launcher. One of which will either resume the application if it is running or force close if it is not running. The second will behave as normal - launches the application normally and resumes normally.
I am very confused, as I was not doing anything (that I can think of) to cause this problem. I was not changing anything whatsoever in the manifest and just implementing a few new methods to change colors in my app faster.
These problems persist identically in all my emulators and devices whether I turn off the phone, manually kill the app or uninstall/reinstall the app. A simple ctrl+z did not work. To clarify - all I would like is to go back to have one launcher icon to launch my application normally (nothing special goes on at all).
Update:
I am now presented with an immediate force close on launching from either icon. I did find code within two activities within my Manifest displaying and changing the second line from .LAUNCHER to .DEFAULT did fix my original problem. However, I am now always presented with an immediate force close...there are now problems (that I can see) within my originally launcher activity...I am having a lot of trouble attempting to fix this (have no idea what to do) and am starting to become VERY worried!
Update 2:
I found my problems and I thank you guys for all your help! I actually had two separate and unrelated problems that occurred at the same time. Number one - two icons in my launcher: caused because I had two activities with a
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
两项活动已
删除第二项
two activities have
remove second one
实际上,Android Launcher 显示类别为 LAUNCHER 的所有活动,而不是应用程序。
如果您的应用程序包含超过 1 个活动,则您必须仅将操作 MAIN 和类别 LAUNCHER 用于应用程序的默认活动(初始屏幕),而不是用于您在应用程序中使用的所有活动。如果您为应用程序中的每个活动添加相同的内容,它将显示在 Android 启动器中。
请阅读意图操作和类别,您就会明白。
Actually Android Launcher displays all activities with category LAUNCHER not applications.
If your application contains more than 1 activity, you have to use action MAIN and category LAUNCHER for your default activity (initial screen) of application only, not for all activities you used in application. If you put same for every activity in application it will be displayed in Android Launcher.
Please read about the Intent Actions and Categories, you will understood.
嗯,我面临着同样的问题。问题是当我运行应用程序时,它正在创建两个图标,一个名称为 MyApp,另一个名称为 SplashActivity。
当我尝试卸载 SplashActivity(名为应用程序)时,在确认消息中显示
查看了一些参考资料后,得出的结论是,当我们放入
任何 Activity 下时,Android 会认为这是 App 的 MAIN 入口点。并为该活动创建一个启动器图标。但名称保留为 ActivityName。
所以最后通过将 SplashActivity 的 Activity 标签从 更改为
它
解决了我的多个图标和启动器图标名称为 ActivityName 而不是 appName 的问题。
Well , I was facing same problem. Problem was when I RUN app, it was creating two icons one with name MyApp and other with SplashActivity.
When I was attempting to uninstall SplashActivity (named app), in Confirmation message it was saying
After looking at some references, concluded that when we put
under any activity, android thinks that this is the MAIN entry point of App. And creates an launcher icon for that activity. but name was kept as acivityName.
So Finally by changing Activity tag of SplashActivity from
to
It solved my issue of multiple icons and launcher icon name as activityName instead of appName.
就我而言,帮助了类似的事情
清单文件中的旧一行
启动屏幕活动
主要活动
和新的
启动屏幕活动
主要活动
只需在主要活动中删除下面的这一行
就是这样!
In my case, helped somethning like that
The old one lines from the manifest file
Splash screen activity
Main Activity
And the new one
Splash screen activity
Main Activity
Just remove in Main Activity this line below
And that's it !
在 AndroidMenifest.xml 文件中,您必须删除两个或三个 android 名称,即
in AndroidMenifest.xml file you have to remove two or three android name i.e