从启动器中删除但保持启用/可启动
我尝试编码它,我尝试用谷歌和stackoverflow解决它,没有找到:=)所以希望其他人有更好的想法,我不确定我是否一切都正确:
我有2个应用程序:广告(主应用程序)/无广告-专业版(只需许可证启动没有广告的广告应用程序;P)
所以问题是,我想在启动器中有一个专业版(带有专业图标),它启动普通广告应用程序,即(普通广告-app)不在启动器中。
我尝试从启动器中删除广告应用程序(根据我的研究,应该将其从启动器中删除)
pkgMgr.setComponentEnabledSetting(new ComponentName(PACKAGE_NAME, PACKAGE_NAME + ".Main"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED、PackageManager.DONT_KILL_APP);
结果是:启动器中的图标是正确的;)但是无法在手机上找到该应用程序、启动、启动,甚至不使用启动器专业版活动快捷方式。它似乎在那里(可以创建快捷方式),但是当我尝试启动它时,我因活动异常而崩溃。
02-18 14:38:59.237:错误/AndroidRuntime(9941):导致:android.content.ActivityNotFoundException:无法找到显式活动类{PACKAGE_NAME/PACKAGE_NAME.Main};您是否在 AndroidManifest.xml 中声明了此活动?
这似乎不属于(错误消息) 看起来应用程序发生的事情不仅仅是简单地删除启动器中的条目。
非常感谢大家, 对于这种情况的每一种解决方法表示赞赏:) 此致 :)
i tried coding it, i tried solving it with google and stackoverflow, nothing found :=) so hopefully someone else has a better idea, im not sure if i get everything right:
i have 2 applications: ad (main app) / adfree-pro (just license starts ad app without ads ;P)
so the problem is, i want to have a pro version (with pro icon) in the launcher, which starts the normal-ad app, which is (the normal ad-app) not in the launcher.
i tried removing the ad-app from the launcher (which due to my research should JUST remove it from the launcher)
pkgMgr.setComponentEnabledSetting(new ComponentName(PACKAGE_NAME, PACKAGE_NAME + ".Main"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
which results to: the icons in the launcher are correct ;) BUT the application can't be found on the phone, launched, started, even not with a launcher pro activity shortcut. it seems to be there (shortcuts can be created) but i crashes with an activity exception when i try to launch it.
02-18 14:38:59.237: ERROR/AndroidRuntime(9941): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {PACKAGE_NAME/PACKAGE_NAME.Main}; have you declared this activity in your AndroidManifest.xml?
which doesnt seem to belong (the error message)
it looks like there has happened more to the application than just simply removed the entry in the launcher.
thanks a lot guys,
every workaround for this situation appreciated :)
best regards :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法安装应用程序并隐藏其启动器图标。我用我的应用程序解决这个问题的方式与你的应用程序类似,我不会尝试与图标战斗,而是可以使用以太图标启动该应用程序。显然,您不必在主(免费)应用程序中执行此操作,从专业图标启动应用程序的代码将如下所示:
由您来实现
appExists()
,即可能是某种许可证检查当然,您也可以将应用程序的通用代码开发为 library项目,然后以两种方式分发它,而无需重复代码
You can't have app installed and hide it's launcher icon. The way I'm addressing it with my application which works similar to yours that I don't try to fight icons but instead the app can be launched using ether icon. Obviously you don't have to do in the main (free) app and the code that launches app from your pro icon will look something like the following:
It's up to you to implement
appExists()
which is probably some sort of license checkOf course, alternatively you can develop your app's common code as library project and then distribute it in 2 flavors without duplicating the code
不是应用程序,而是活动。
因此,如果您的
LAUNCHER
活动是BaseActivity
,您可以创建类似BaseFakeActivity
的内容(不要忘记将其设置为>LAUNCHER
在你的清单中,而不是你的BaseActivity
),其唯一的功能是启动你的BaseActivity
然后finish()
本身。现在您可以隐藏您的
BaseFakeActivity
,但您仍然可以与您的BaseActivity
进行交互。PS:在这样做之后,不要忘记测试应用程序的行为;)
Not application, but activity.
So, if your
LAUNCHER
activity isBaseActivity
, you may create something likeBaseFakeActivity
(don't forget to set it asLAUNCHER
in your manifest instead of yourBaseActivity
) and which only function is to start yourBaseActivity
and thenfinish()
itself.Now you may hide your
BaseFakeActivity
but you'll still be possible to interact with yourBaseActivity
.P.S.: Don't forget to test your app's behaviour after doing things this way ;)