简体   繁体   English

Android以编程方式隐藏应用程序图标

[英]Android hide app icon programatically

I have been trying to hide my app's icon from the app drawer and open it from dialler. 我一直在尝试从应用程序抽屉中隐藏我的应用程序图标,并从Dialler中打开它。 The dialler part works perfertly, but i am having issues with hiding it. 拨号器部分工作正常,但是隐藏它存在问题。 My problem is, if i hide my activity, it's get destroyed and i can no longer access it from my dialler. 我的问题是,如果我隐藏活动,活动将被销毁,并且无法再通过拨号程序访问它。 I have tried creating a duplicate activity as suggested here , but if i do that then my initial problem of hiding the icon is not solved. 我尝试按照此处的建议创建重复的活动,但是如果我这样做,那么隐藏图标的最初问题将无法解决。

Any ideas would be greatly appreciated. 任何想法将不胜感激。

I was doing it wrong. 我做错了。 Just set the MainActivity as the launcher and set a duplicate activity in the dialler. 只需将MainActivity设置为启动器,然后在Dialler中设置重复的活动即可。

Please use this. 请使用这个。

PackageManager pkg=this.getPackageManager(); PackageManager pkg = this.getPackageManager(); pkg.setComponentEnabledSetting(new ComponentName(this,SplashActivity.class),PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pkg.setComponentEnabledSetting(新的ComponentName(this,SplashActivity.class),PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM