Reading android manifest file

穿精又带淫゛_ 提交于 2019-12-02 04:36:05

[Edit after OP's comment] : You can use Android's PackageManaer http://developer.android.com/reference/android/content/pm/PackageManager.html to get information about the contents of the manifest file that Android understands.

As already suggested, you can use the PackageManager for this purpose. There are several methods that are able to return one or more PackageInfo objects, which on their turn contain a public field ActivityInfo[] activities, provided you instruct it too... read below.

The documentation mentions the following:

Array of all tags included under , or null if there were none. This is only filled in if the flag GET_ACTIVITIES was set.

So make sure that you provide that particular flag when requesting the info; e.g. when using getPackageInfo(...), do:

getPackageInfo("your.package.name", PackageManager.GET_ACTIVITIES)

If you need to retrieve more details, you can 'or' multiple flags together:

getPackageInfo("your.package.name", PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS)

Edit:

Alternatively you could also use the getActivityInfo(android.content.ComponentName, int) and catch the NameNotFoundException that will be thrown if the requested Activity cannot be found, but generally this is considered 'abusing' exceptions.

Anyways, up to you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!