Reading Android manifest file

Is it possible to read / parse the android manifest file in some way, as we do this for files in the raw folder, as indicated here:

http://eagle.phys.utk.edu/guidry/android/writeSD.html

getResources.ReadManifest..something like this ??

thanks
Sneha

+1
android file manifest
source share
2 answers

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

0
source share

As already suggested, you can use the PackageManager for this purpose. There are several methods that can return one or more PackageInfo objects, which in turn contain the public field ActivityInfo[] activities , if you also instruct it ... read below.

The documentation mentions the following:

An array of all tags included under, or null if there were none. This is only populated if the GET_ACTIVITIES flag is set.

Thus, make sure you specify this special flag when requesting information; for example, when using getPackageInfo(...) do:

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

If you need more detailed information, you can add several flags "or":

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

Edit:

Alternatively, you can also use getActivityInfo(android.content.ComponentName, int) and catch a NameNotFoundException that will be NameNotFoundException if the requested Activity cannot be found, but in general this is considered an β€œabuse” of exceptions.

Anyway, up to you.

+4
source share

All Articles