I have an app that has intent filters set to CategoryHome
and CategoryDefault
[IntentFilter
(
new[]
{
Intent.ActionMain
},
Categories = new[]
{
Intent.CategoryHome,
Intent.CategoryDefault
}
)
]
public class MainActivity : Activity
...
Is it possible to change this on the fly?
Pragmatically set Intent Categories - Home Button Action
You can't do this directly, but you could disable/enable particular Activities
of your app. So you could have your Home app as disabled by default, then if a user wanted to use it, they could enable it programmatically.
You could refer to CommonsWare's answer :
You can neither enable, disable, or create
<intent-filter>
s programmatically.However, in your case, you only have one
<intent-filter>
per component. In that case, you can enable and disable the component programmatically, viaPackageManager
andsetComponentEnabledSetting()
. In your case, enabling or disabling the activity would have the same basic effect as enabling or disabling its<intent-filter>
.
Other useful link :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.