任何的方法来检查,如果在机器人的活动注册在manifest文件?方法来、机器人、文件、manifest

2023-09-12 06:09:14 作者:玩世不恭的男人

有没有什么办法来检查,如果在机器人的活动注册在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.