I am working on an Android application that requires more information than what is available in the PackageManager
(such as intent filters). I have created a parser for reading the AndroidManifest file, but I cannot find the location of the AndroidManifest.xml
for any installed application. The code I am using is:
int flags = PackageManager.GET_ACTIVITIES
//| PackageManager.GET_CONFIGURATIONS
//| PackageManager.GET_DISABLED_COMPONENTS
//| PackageManager.GET_GIDS
//| PackageManager.GET_INSTRUMENTATION
//| PackageManager.GET_INTENT_FILTERS //Not needed (see BUG: http://code.google.com/p/android/issues/detail?id=3217)
| PackageManager.GET_META_DATA
| PackageManager.GET_PERMISSIONS
| PackageManager.GET_PROVIDERS
| PackageManager.GET_RECEIVERS
| PackageManager.GET_RESOLVED_FILTER
| PackageManager.GET_SERVICES
| PackageManager.GET_SHARED_LIBRARY_FILES
| PackageManager.GET_SIGNATURES
| PackageManager.GET_UNINSTALLED_PACKAGES
| PackageManager.GET_URI_PERMISSION_PATTERNS;
final PackageInfo pkg = pm.getPackageInfo(info.packageName, flags);
File manifest = new File(pkg.applicationInfo.publicSourceDir + "/AndroidManifest.xml");
if (manifest.exists()) {
//Code never reaches this point
}
According to the documentation, ApplicationInfo.publicSourceDir is:
Full path to the location of the publicly available parts of this package (i.e. the primary resource package and manifest). For non-forward-locked apps this will be the same as {@link #sourceDir).
What am I doing wrong, or how can I do this right?