Android: Can I enable/disable an activity's intent filter programmatically?

后端 未结 1 659
眼角桃花
眼角桃花 2020-11-30 06:10

I need to hide or show my app\'s icon in the launcher depending on some runtime information. I\'d like to still be able to run the activity by an explicit intent, so disabli

相关标签:
1条回答
  • 2020-11-30 06:34

    You can't do this directly, but you can create an activity alias in your AndroidManifest.xml with the intent filter in question, and then enable or disable the alias using PackageManager#setComponentEnabledSetting(), leaving your other intent filters in the main copy of the Activity so they won't be affected.

    0 讨论(0)
提交回复
热议问题