[英]Pragmatically set Intent Categories - Home Button Action
I have an app that has intent filters set to CategoryHome
and CategoryDefault
我有一个将意图过滤器设置为
CategoryHome
和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. 您不能直接执行此操作,但是可以禁用/启用应用程序的特定
Activities
。 So you could have your Home app as disabled by default, then if a user wanted to use it, they could enable it programmatically. 因此,您可以默认禁用Home应用程序,然后,如果用户想使用它,则可以通过编程方式启用它。
You could refer to CommonsWare's answer : 您可以参考CommonsWare的答案 :
You can neither enable, disable, or create
<intent-filter>
s programmatically.您不能以编程方式启用,禁用或创建
<intent-filter>
。However, in your case, you only have one
<intent-filter>
per component.但是,根据您的情况,每个组件只有一个
<intent-filter>
。 In that case, you can enable and disable the component programmatically, viaPackageManager
andsetComponentEnabledSetting()
.在这种情况下,您可以通过
PackageManager
和setComponentEnabledSetting()
编程方式启用和禁用组件 。 In your case, enabling or disabling the activity would have the same basic effect as enabling or disabling its<intent-filter>
.在您的情况下,启用或禁用活动与启用或禁用其
<intent-filter>
具有相同的基本效果。
Other useful link : 其他有用的链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.