Class AndroidManifest

  • All Implemented Interfaces:
    org.robolectric.pluginapi.UsesSdk

    public class AndroidManifest
    extends java.lang.Object
    implements org.robolectric.pluginapi.UsesSdk
    A wrapper for an Android App Manifest, which represents information about one's App to an Android system.
    See Also:
    Android App Manifest
    • Constructor Detail

      • AndroidManifest

        public AndroidManifest​(java.nio.file.Path androidManifestFile,
                               java.nio.file.Path resDirectory,
                               java.nio.file.Path assetsDirectory)
        Creates a Robolectric configuration using specified locations.
        Parameters:
        androidManifestFile - Location of the AndroidManifest.xml file.
        resDirectory - Location of the res directory.
        assetsDirectory - Location of the assets directory.
      • AndroidManifest

        public AndroidManifest​(java.nio.file.Path androidManifestFile,
                               java.nio.file.Path resDirectory,
                               java.nio.file.Path assetsDirectory,
                               java.lang.String overridePackageName)
        Creates a Robolectric configuration using specified values.
        Parameters:
        androidManifestFile - Location of the AndroidManifest.xml file.
        resDirectory - Location of the res directory.
        assetsDirectory - Location of the assets directory.
        overridePackageName - Application package name.
      • AndroidManifest

        public AndroidManifest​(java.nio.file.Path androidManifestFile,
                               java.nio.file.Path resDirectory,
                               java.nio.file.Path assetsDirectory,
                               @Nonnull
                               java.util.List<AndroidManifest> libraryManifests,
                               java.lang.String overridePackageName)
        Creates a Robolectric configuration using specified values.
        Parameters:
        androidManifestFile - Location of the AndroidManifest.xml file.
        resDirectory - Location of the res directory.
        assetsDirectory - Location of the assets directory.
        libraryManifests - List of dependency library manifests.
        overridePackageName - Application package name.
      • AndroidManifest

        public AndroidManifest​(java.nio.file.Path androidManifestFile,
                               java.nio.file.Path resDirectory,
                               java.nio.file.Path assetsDirectory,
                               @Nonnull
                               java.util.List<AndroidManifest> libraryManifests,
                               java.lang.String overridePackageName,
                               java.nio.file.Path apkFile)
    • Method Detail

      • getThemeRef

        public java.lang.String getThemeRef​(java.lang.String activityClassName)
      • getRClassName

        public java.lang.String getRClassName()
                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getRClass

        public java.lang.Class getRClass()
      • initMetaData

        public void initMetaData​(ResourceTable resourceTable)
                          throws RoboNotFoundException
        Allows ShadowPackageManager to provide a resource index for initialising the resource attributes in all the metadata elements
        Parameters:
        resourceTable - used for getting resource IDs from string identifiers
        Throws:
        RoboNotFoundException
      • getApplicationName

        public java.lang.String getApplicationName()
      • getActivityLabel

        public java.lang.String getActivityLabel​(java.lang.String activityClassName)
      • getPackageName

        public java.lang.String getPackageName()
      • getVersionCode

        public int getVersionCode()
      • getVersionName

        public java.lang.String getVersionName()
      • getLabelRef

        public java.lang.String getLabelRef()
      • getMinSdkVersion

        public int getMinSdkVersion()
        Returns the minimum Android SDK version that this package expects to be runnable on, as specified in the manifest.

        Note that if targetSdkVersion isn't set, this value changes the behavior of some Android code (notably android.content.SharedPreferences) to emulate old bugs.

        Specified by:
        getMinSdkVersion in interface org.robolectric.pluginapi.UsesSdk
        Returns:
        the minimum SDK version, or Jelly Bean (16) by default
      • getTargetSdkVersion

        public int getTargetSdkVersion()
        Returns the Android SDK version that this package prefers to be run on, as specified in the manifest.

        Note that this value changes the behavior of some Android code (notably android.content.SharedPreferences) to emulate old bugs.

        Specified by:
        getTargetSdkVersion in interface org.robolectric.pluginapi.UsesSdk
        Returns:
        the minimum SDK version, or Jelly Bean (16) by default
      • getMaxSdkVersion

        public java.lang.Integer getMaxSdkVersion()
        Specified by:
        getMaxSdkVersion in interface org.robolectric.pluginapi.UsesSdk
      • getApplicationAttributes

        public java.util.Map<java.lang.String,​java.lang.String> getApplicationAttributes()
      • getProcessName

        public java.lang.String getProcessName()
      • getApplicationMetaData

        public java.util.Map<java.lang.String,​java.lang.Object> getApplicationMetaData()
      • getIncludedResourcePaths

        public java.util.List<ResourcePath> getIncludedResourcePaths()
      • getLibraryManifests

        public java.util.List<AndroidManifest> getLibraryManifests()
      • getAllManifests

        public java.util.List<AndroidManifest> getAllManifests()
        Returns all transitively reachable manifests, including this one, in order and without duplicates.
      • getResDirectory

        public java.nio.file.Path getResDirectory()
      • getAssetsDirectory

        public java.nio.file.Path getAssetsDirectory()
      • getAndroidManifestFile

        public java.nio.file.Path getAndroidManifestFile()
      • getServices

        public java.util.List<ServiceData> getServices()
      • getServiceData

        public ServiceData getServiceData​(java.lang.String serviceClassName)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getActivityData

        public ActivityData getActivityData​(java.lang.String activityClassName)
      • getThemeRef

        public java.lang.String getThemeRef()
      • getActivityDatas

        public java.util.Map<java.lang.String,​ActivityData> getActivityDatas()
      • getUsedPermissions

        public java.util.List<java.lang.String> getUsedPermissions()
      • getPermissions

        public java.util.Map<java.lang.String,​PermissionItemData> getPermissions()
      • getBroadcastReceiver

        @Nullable
        public BroadcastReceiverData getBroadcastReceiver​(java.lang.String className)
        Returns data for the broadcast receiver with the provided name from this manifest. If no receiver with the class name can be found, returns null.
        Parameters:
        className - the fully resolved class name of the receiver
        Returns:
        data for the receiver or null if it cannot be found
      • getApkFile

        public java.nio.file.Path getApkFile()
      • supportsLegacyResourcesMode

        @Deprecated
        public boolean supportsLegacyResourcesMode()
        Deprecated.
        Do not use.
      • supportsBinaryResourcesMode

        @Deprecated
        public boolean supportsBinaryResourcesMode()
        Deprecated.
        Do not use.