Package org.robolectric.manifest
Class AndroidManifest
java.lang.Object
org.robolectric.manifest.AndroidManifest
- All Implemented Interfaces:
UsesSdk
public class AndroidManifest extends Object implements 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 Summary
Constructors Constructor Description AndroidManifest(Path androidManifestFile, Path resDirectory, Path assetsDirectory)
Creates a Robolectric configuration using specified locations.AndroidManifest(Path androidManifestFile, Path resDirectory, Path assetsDirectory, String overridePackageName)
Creates a Robolectric configuration using specified values.AndroidManifest(Path androidManifestFile, Path resDirectory, Path assetsDirectory, List<AndroidManifest> libraryManifests, String overridePackageName)
Creates a Robolectric configuration using specified values.AndroidManifest(Path androidManifestFile, Path resDirectory, Path assetsDirectory, List<AndroidManifest> libraryManifests, String overridePackageName, Path apkFile)
-
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
ActivityData
getActivityData(String activityClassName)
Map<String,ActivityData>
getActivityDatas()
String
getActivityLabel(String activityClassName)
List<AndroidManifest>
getAllManifests()
Returns all transitively reachable manifests, including this one, in order and without duplicates.Path
getAndroidManifestFile()
Path
getApkFile()
Map<String,String>
getApplicationAttributes()
Map<String,Object>
getApplicationMetaData()
String
getApplicationName()
Path
getAssetsDirectory()
BroadcastReceiverData
getBroadcastReceiver(String className)
Returns data for the broadcast receiver with the provided name from this manifest.List<BroadcastReceiverData>
getBroadcastReceivers()
List<ContentProviderData>
getContentProviders()
List<ResourcePath>
getIncludedResourcePaths()
String
getLabelRef()
List<AndroidManifest>
getLibraryManifests()
Integer
getMaxSdkVersion()
Returns the maximum Android SDK version that this package expects to be runnable on, as specified in the manifest.int
getMinSdkVersion()
Returns the minimum Android SDK version that this package expects to be runnable on, as specified in the manifest.String
getPackageName()
Map<String,PermissionGroupItemData>
getPermissionGroups()
Map<String,PermissionItemData>
getPermissions()
String
getProcessName()
Class
getRClass()
String
getRClassName()
Path
getResDirectory()
ResourcePath
getResourcePath()
ServiceData
getServiceData(String serviceClassName)
List<ServiceData>
getServices()
int
getTargetSdkVersion()
Returns the Android SDK version that this package prefers to be run on, as specified in the manifest.String
getThemeRef()
String
getThemeRef(String activityClassName)
List<String>
getUsedPermissions()
int
getVersionCode()
String
getVersionName()
int
hashCode()
void
initMetaData(ResourceTable resourceTable)
Allows ShadowPackageManager to provide a resource index for initialising the resource attributes in all the metadata elementsboolean
supportsBinaryResourcesMode()
Deprecated.Do not use.boolean
supportsLegacyResourcesMode()
Deprecated.Do not use.
-
Constructor Details
-
AndroidManifest
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(Path androidManifestFile, Path resDirectory, Path assetsDirectory, 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(Path androidManifestFile, Path resDirectory, Path assetsDirectory, @Nonnull List<AndroidManifest> libraryManifests, 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
-
-
Method Details
-
getThemeRef
-
getRClassName
- Throws:
Exception
-
getRClass
-
initMetaData
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
-
getActivityLabel
-
getPackageName
-
getVersionCode
public int getVersionCode() -
getVersionName
-
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 (notablySharedPreferences
) to emulate old bugs.- Specified by:
getMinSdkVersion
in interfaceUsesSdk
- 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
SharedPreferences
) to emulate old bugs.- Specified by:
getTargetSdkVersion
in interfaceUsesSdk
- Returns:
- the minimum SDK version, or Jelly Bean (16) by default
-
getMaxSdkVersion
Description copied from interface:UsesSdk
Returns the maximum Android SDK version that this package expects to be runnable on, as specified in the manifest.If no maximum version is specified, null may be returned.
- Specified by:
getMaxSdkVersion
in interfaceUsesSdk
- Returns:
- the maximum SDK version, or null
-
getApplicationAttributes
-
getProcessName
-
getApplicationMetaData
-
getResourcePath
-
getIncludedResourcePaths
-
getContentProviders
-
getLibraryManifests
-
getAllManifests
Returns all transitively reachable manifests, including this one, in order and without duplicates. -
getResDirectory
-
getAssetsDirectory
-
getAndroidManifestFile
-
getBroadcastReceivers
-
getServices
-
getServiceData
-
equals
-
hashCode
public int hashCode() -
getActivityData
-
getThemeRef
-
getActivityDatas
-
getUsedPermissions
-
getPermissions
-
getPermissionGroups
-
getBroadcastReceiver
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
-
supportsLegacyResourcesMode
Deprecated.Do not use. -
supportsBinaryResourcesMode
Deprecated.Do not use.
-