任何的方法来检查,如果在机器人的活动注册在manifest文件? [英] Any way to check if an Activity in android is registered in manifest file?

查看:120
本文介绍了任何的方法来检查,如果在机器人的活动注册在manifest文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法来检查,如果在机器人的活动注册在manifest文件开始之前?

Is there any way to check if an Activity in android is registered in manifest file before starting it?

说,例如:

 String test = "com.Hy5.activity.Navigate";  
             Intent intent = new Intent().setClassName(this.context,
                 test);                  intent.putExtra("params", params);  


            try {  
                ((Activity) context).startActivity(intent);  
            } catch (Exception e) {  
                            //e.printStackTrace();
        } // This Activity will implement 

在这里,我要检查,如果测试活动已登记在清单或不。

Here I want to check if Test activity has been registered in manifest or not.

或者有什么办法可以读/解析这个manifest.xml的在应用程序包,就像我做的说:getResources()的getString(R.string.Sprint1)?

Or is there any way I can read/parse this manifest.xml in application package just like i do for say: getResources().getString(R.string.Sprint1)??

推荐答案

使用PackageManager.getActivityInfo() 这将引发PackageManager.NameNotFoundException如果它不存在

Use PackageManager.getActivityInfo() It will throw PackageManager.NameNotFoundException if it's not there

不知道你会做这个,虽然赢得任何东西。

Not sure you will gain anything by doing this though.

这篇关于任何的方法来检查,如果在机器人的活动注册在manifest文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆