网上搜的大部分隐藏图标方式并不准确,那么多小白隐藏了图标但是application都没运行?
首先科普,这篇文章非常好:https://blog.csdn.net/lindroid20/article/details/51993247/
先记录网上大部分的信息:
直接隐藏掉activity的图标启动,会报红叉错误,这个是因为android studio设置了默认启动方式而你却把默认启动方式给去掉了,解决方案如下:https://blog.csdn.net/ljheee/article/details/70140310
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
好,launcer注释掉了,launch方式换成了nothing,项目也确实运行起来了,图标没有了,可是application、activity和service的onCreate()都没有运行?(为什么不是很清楚如果有大侠请留下解决方案)
连log都没有。控制台上可以看到该进程处于[DEAD]状态,但是代码确实运行了。代码方面一点都没有跑(日志文件都没有创建),那么这种方式只是达到了隐藏图标而已,对开发者来说就是个假隐藏。
-那么应该怎么做呢?
——————分界线
隐式启动的方式,参考大佬:https://blog.csdn.net/rgen_xiao/article/details/51219184
<intent-filter> <action android:name="android.intent.action.MAIN" /> <data android:scheme="myapp" android:host=".app" android:pathPrefix="/openwith"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
即添加<data>标签,这种方式源自网页调取app的方式:https://blog.csdn.net/jiangwei0910410003/article/details/23940445
网页调取APP还需要添加一些东西,参考:https://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-app
<data>标签属性:
scheme:判别启动的App。
host:适当记述。
细看的话点开大佬链接学习一下吧。
——————分界线
关于第一部分,无图标的app一般也是无界面的,在<application>属性中,把theme改为:
android:theme="@android:style/Theme.NoDisplay"
如果只改了无界面,没有把图标隐藏的话,运行确实是无界面的。但是在rk3399-7.1.2系统中运行的时候发现,运行后持续按ESC键会导致程序关闭,也会出现偶尔的卡顿。用第二部分隐式启动的方式很流畅且没问题。