PackageManager.ParseAndroidManifest(File, IFunction) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieve AndroidManifest.
[Android.Runtime.Register("parseAndroidManifest", "(Ljava/io/File;Ljava/util/function/Function;)Ljava/lang/Object;", "GetParseAndroidManifest_Ljava_io_File_Ljava_util_function_Function_Handler", ApiSince=35)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public virtual Java.Lang.Object? ParseAndroidManifest (Java.IO.File apkFile, Java.Util.Functions.IFunction parserFunction);
[<Android.Runtime.Register("parseAndroidManifest", "(Ljava/io/File;Ljava/util/function/Function;)Ljava/lang/Object;", "GetParseAndroidManifest_Ljava_io_File_Ljava_util_function_Function_Handler", ApiSince=35)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
abstract member ParseAndroidManifest : Java.IO.File * Java.Util.Functions.IFunction -> Java.Lang.Object
override this.ParseAndroidManifest : Java.IO.File * Java.Util.Functions.IFunction -> Java.Lang.Object
Parameters
- apkFile
- File
The file of an application apk.
- parserFunction
- IFunction
The parserFunction will be invoked with the XmlResourceParser object after getting the AndroidManifest.xml of an application package.
Returns
Returns the result of the Function#apply(Object)
.
- Attributes
Remarks
Retrieve AndroidManifest.xml information for the given application apk file.
Example:
<code>
Bundle result;
try {
result = getContext().getPackageManager().parseAndroidManifest(apkFile,
xmlResourceParser -> {
Bundle bundle = new Bundle();
// Search the start tag
int type;
while ((type = xmlResourceParser.next()) != XmlPullParser.START_TAG
&& type != XmlPullParser.END_DOCUMENT) {
}
if (type != XmlPullParser.START_TAG) {
return bundle;
}
// Start to read the tags and attributes from the xmlResourceParser
if (!xmlResourceParser.getName().equals("manifest")) {
return bundle;
}
String packageName = xmlResourceParser.getAttributeValue(null, "package");
bundle.putString("package", packageName);
// Continue to read the tags and attributes from the xmlResourceParser
return bundle;
});
} catch (IOException e) {
}
</code>
Note: When the parserFunction is invoked, the client can read the AndroidManifest.xml information by the XmlResourceParser object. After leaving the parserFunction, the XmlResourceParser object will be closed. The caller should also handle the exception for calling this method.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.