Class AndroidManifest


  • public final class AndroidManifest
    extends java.lang.Object
    Helper and Constants for the AndroidManifest.xml file.
    • Field Detail

      • NODE_APPLICATION

        public static final java.lang.String NODE_APPLICATION
        See Also:
        Constant Field Values
      • NODE_ACTIVITY_ALIAS

        public static final java.lang.String NODE_ACTIVITY_ALIAS
        See Also:
        Constant Field Values
      • NODE_PERMISSION_TREE

        public static final java.lang.String NODE_PERMISSION_TREE
        See Also:
        Constant Field Values
      • NODE_PERMISSION_GROUP

        public static final java.lang.String NODE_PERMISSION_GROUP
        See Also:
        Constant Field Values
      • NODE_USES_PERMISSION

        public static final java.lang.String NODE_USES_PERMISSION
        See Also:
        Constant Field Values
      • NODE_INSTRUMENTATION

        public static final java.lang.String NODE_INSTRUMENTATION
        See Also:
        Constant Field Values
      • NODE_USES_LIBRARY

        public static final java.lang.String NODE_USES_LIBRARY
        See Also:
        Constant Field Values
      • NODE_SUPPORTS_SCREENS

        public static final java.lang.String NODE_SUPPORTS_SCREENS
        See Also:
        Constant Field Values
      • NODE_COMPATIBLE_SCREENS

        public static final java.lang.String NODE_COMPATIBLE_SCREENS
        See Also:
        Constant Field Values
      • NODE_USES_CONFIGURATION

        public static final java.lang.String NODE_USES_CONFIGURATION
        See Also:
        Constant Field Values
      • NODE_USES_FEATURE

        public static final java.lang.String NODE_USES_FEATURE
        See Also:
        Constant Field Values
      • NODE_GRANT_URI_PERMISSION

        public static final java.lang.String NODE_GRANT_URI_PERMISSION
        See Also:
        Constant Field Values
      • NODE_PATH_PERMISSION

        public static final java.lang.String NODE_PATH_PERMISSION
        See Also:
        Constant Field Values
      • NODE_SUPPORTS_GL_TEXTURE

        public static final java.lang.String NODE_SUPPORTS_GL_TEXTURE
        See Also:
        Constant Field Values
      • ATTRIBUTE_PACKAGE

        public static final java.lang.String ATTRIBUTE_PACKAGE
        See Also:
        Constant Field Values
      • ATTRIBUTE_VERSIONCODE

        public static final java.lang.String ATTRIBUTE_VERSIONCODE
        See Also:
        Constant Field Values
      • ATTRIBUTE_MIME_TYPE

        public static final java.lang.String ATTRIBUTE_MIME_TYPE
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQUIRED

        public static final java.lang.String ATTRIBUTE_REQUIRED
        See Also:
        Constant Field Values
      • ATTRIBUTE_GLESVERSION

        public static final java.lang.String ATTRIBUTE_GLESVERSION
        See Also:
        Constant Field Values
      • ATTRIBUTE_PROCESS

        public static final java.lang.String ATTRIBUTE_PROCESS
        See Also:
        Constant Field Values
      • ATTRIBUTE_DEBUGGABLE

        public static final java.lang.String ATTRIBUTE_DEBUGGABLE
        See Also:
        Constant Field Values
      • ATTRIBUTE_MIN_SDK_VERSION

        public static final java.lang.String ATTRIBUTE_MIN_SDK_VERSION
        See Also:
        Constant Field Values
      • ATTRIBUTE_TARGET_SDK_VERSION

        public static final java.lang.String ATTRIBUTE_TARGET_SDK_VERSION
        See Also:
        Constant Field Values
      • ATTRIBUTE_TARGET_PACKAGE

        public static final java.lang.String ATTRIBUTE_TARGET_PACKAGE
        See Also:
        Constant Field Values
      • ATTRIBUTE_TARGET_ACTIVITY

        public static final java.lang.String ATTRIBUTE_TARGET_ACTIVITY
        See Also:
        Constant Field Values
      • ATTRIBUTE_MANAGE_SPACE_ACTIVITY

        public static final java.lang.String ATTRIBUTE_MANAGE_SPACE_ACTIVITY
        See Also:
        Constant Field Values
      • ATTRIBUTE_EXPORTED

        public static final java.lang.String ATTRIBUTE_EXPORTED
        See Also:
        Constant Field Values
      • ATTRIBUTE_RESIZEABLE

        public static final java.lang.String ATTRIBUTE_RESIZEABLE
        See Also:
        Constant Field Values
      • ATTRIBUTE_ANYDENSITY

        public static final java.lang.String ATTRIBUTE_ANYDENSITY
        See Also:
        Constant Field Values
      • ATTRIBUTE_SMALLSCREENS

        public static final java.lang.String ATTRIBUTE_SMALLSCREENS
        See Also:
        Constant Field Values
      • ATTRIBUTE_NORMALSCREENS

        public static final java.lang.String ATTRIBUTE_NORMALSCREENS
        See Also:
        Constant Field Values
      • ATTRIBUTE_LARGESCREENS

        public static final java.lang.String ATTRIBUTE_LARGESCREENS
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQ_5WAYNAV

        public static final java.lang.String ATTRIBUTE_REQ_5WAYNAV
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQ_NAVIGATION

        public static final java.lang.String ATTRIBUTE_REQ_NAVIGATION
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQ_HARDKEYBOARD

        public static final java.lang.String ATTRIBUTE_REQ_HARDKEYBOARD
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQ_KEYBOARDTYPE

        public static final java.lang.String ATTRIBUTE_REQ_KEYBOARDTYPE
        See Also:
        Constant Field Values
      • ATTRIBUTE_REQ_TOUCHSCREEN

        public static final java.lang.String ATTRIBUTE_REQ_TOUCHSCREEN
        See Also:
        Constant Field Values
      • ATTRIBUTE_BACKUP_AGENT

        public static final java.lang.String ATTRIBUTE_BACKUP_AGENT
        See Also:
        Constant Field Values
      • ATTRIBUTE_PARENT_ACTIVITY_NAME

        public static final java.lang.String ATTRIBUTE_PARENT_ACTIVITY_NAME
        See Also:
        Constant Field Values
      • ATTRIBUTE_SUPPORTS_RTL

        public static final java.lang.String ATTRIBUTE_SUPPORTS_RTL
        See Also:
        Constant Field Values
      • ATTRIBUTE_UI_OPTIONS

        public static final java.lang.String ATTRIBUTE_UI_OPTIONS
        See Also:
        Constant Field Values
      • VALUE_PARENT_ACTIVITY

        public static final java.lang.String VALUE_PARENT_ACTIVITY
        See Also:
        Constant Field Values
    • Constructor Detail

      • AndroidManifest

        public AndroidManifest()
    • Method Detail

      • getManifest

        public static IAbstractFile getManifest​(IAbstractFolder projectFolder)
        Returns an IAbstractFile object representing the manifest for the given project.
        Parameters:
        projectFolder - The project containing the manifest file.
        Returns:
        An IAbstractFile object pointing to the manifest or null if the manifest is missing.
      • getPackage

        public static java.lang.String getPackage​(IAbstractFolder projectFolder)
                                           throws javax.xml.xpath.XPathExpressionException,
                                                  StreamException
        Returns the package for a given project.
        Parameters:
        projectFolder - the folder of the project.
        Returns:
        the package info or null (or empty) if not found.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getPackage

        public static java.lang.String getPackage​(IAbstractFile manifestFile)
                                           throws javax.xml.xpath.XPathExpressionException,
                                                  StreamException
        Returns the package for a given manifest.
        Parameters:
        manifestFile - the manifest to parse.
        Returns:
        the package info or null (or empty) if not found.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getDebuggable

        public static boolean getDebuggable​(IAbstractFile manifestFile)
                                     throws javax.xml.xpath.XPathExpressionException,
                                            StreamException
        Returns whether the manifest is set to make the application debuggable. If the give manifest does not contain the debuggable attribute then the application is considered to not be debuggable.
        Parameters:
        manifestFile - the manifest to parse.
        Returns:
        true if the application is debuggable.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getVersionCode

        public static int getVersionCode​(IAbstractFile manifestFile)
                                  throws javax.xml.xpath.XPathExpressionException,
                                         StreamException
        Returns the value of the versionCode attribute or -1 if the value is not set.
        Parameters:
        manifestFile - the manifest file to read the attribute from.
        Returns:
        the integer value or -1 if not set.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • hasVersionCode

        public static boolean hasVersionCode​(IAbstractFile manifestFile)
                                      throws javax.xml.xpath.XPathExpressionException,
                                             StreamException
        Returns whether the version Code attribute is set in a given manifest.
        Parameters:
        manifestFile - the manifest to check
        Returns:
        true if the versionCode attribute is present and its value is not empty.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getMinSdkVersion

        @Nullable
        public static java.lang.Object getMinSdkVersion​(IAbstractFile manifestFile)
                                                 throws javax.xml.xpath.XPathExpressionException,
                                                        StreamException
        Returns the value of the minSdkVersion attribute.

        If the attribute is set with an int value, the method returns an Integer object.

        If the attribute is set with a codename, it returns the codename as a String object.

        If the attribute is not set, it returns null.

        Parameters:
        manifestFile - the manifest file to read the attribute from.
        Returns:
        the attribute value.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getTargetSdkVersion

        @Nullable
        public static java.lang.Object getTargetSdkVersion​(IAbstractFile manifestFile)
                                                    throws javax.xml.xpath.XPathExpressionException,
                                                           StreamException
        Returns the value of the targetSdkVersion attribute.

        If the attribute is set with an int value, the method returns an Integer object.

        If the attribute is set with a codename, it returns the codename as a String object.

        If the attribute is not set, it returns null.

        Parameters:
        manifestFile - the manifest file to read the attribute from.
        Returns:
        the integer value or -1 if not set.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getApplicationIcon

        public static java.lang.String getApplicationIcon​(IAbstractFile manifestFile)
                                                   throws javax.xml.xpath.XPathExpressionException,
                                                          StreamException
        Returns the application icon for a given manifest.
        Parameters:
        manifestFile - the manifest to parse.
        Returns:
        the icon or null (or empty) if not found.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getApplicationLabel

        public static java.lang.String getApplicationLabel​(IAbstractFile manifestFile)
                                                    throws javax.xml.xpath.XPathExpressionException,
                                                           StreamException
        Returns the application label for a given manifest.
        Parameters:
        manifestFile - the manifest to parse.
        Returns:
        the label or null (or empty) if not found.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • getSupportsRtl

        public static boolean getSupportsRtl​(IAbstractFile manifestFile)
                                      throws javax.xml.xpath.XPathExpressionException,
                                             StreamException
        Returns whether the manifest is set to make the application RTL aware. If the give manifest does not contain the supportsRtl attribute then the application is considered to not be not supporting RTL (there will be no layout mirroring).
        Parameters:
        manifestFile - the manifest to parse.
        Returns:
        true if the application is supporting RTL.
        Throws:
        javax.xml.xpath.XPathExpressionException
        StreamException - If any error happens when reading the manifest.
      • combinePackageAndClassName

        public static java.lang.String combinePackageAndClassName​(java.lang.String javaPackage,
                                                                  java.lang.String className)
        Combines a java package, with a class value from the manifest to make a fully qualified class name
        Parameters:
        javaPackage - the java package from the manifest.
        className - the class name from the manifest.
        Returns:
        the fully qualified class name.
      • extractActivityName

        public static java.lang.String extractActivityName​(java.lang.String fullActivityName,
                                                           java.lang.String packageName)
        Given a fully qualified activity name (e.g. com.foo.test.MyClass) and given a project package base name (e.g. com.foo), returns the relative activity name that would be used the "name" attribute of an "activity" element.
        Parameters:
        fullActivityName - a fully qualified activity class name, e.g. "com.foo.test.MyClass"
        packageName - The project base package name, e.g. "com.foo"
        Returns:
        The relative activity name if it can be computed or the original fullActivityName.