我想测试应用程序中是否存在名称为“ test”的活动。可能在调用startActivity之前或在其catch块中使用Manifest文件进行以下操作:

Starting an Activity with Intent and SetClassName

所以说:

if(test.exists){
    Activity is registered and start it
}
else{
    create Activity and add it in manifset programmatically, as this would be a dynamic Activity
}

最佳答案

即使您从JSON响应中获取活动,也无法以编程方式在清单文件中添加活动。

而且,如果您要启动本机活动,我们通常根本不将其添加到清单文件中,但是对于某些事情,我们需要添加权限以在我们的应用中使用它们。

关于android - 查找 Activity 是否存在于android中的方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10122470/

10-12 03:14
查看更多