任何的方法来检查,如果在机器人的活动注册在manifest文件? [英] Any way to check if an Activity in android is registered in manifest file?
问题描述
有没有什么办法来检查,如果在机器人的活动注册在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屋!