Deprecated API
Contents
-
Deprecated PackagesPackageDescriptionThis package is no longer maintained and will be removed in Robolectric 4.16.
-
Deprecated InterfacesInterfaceDescriptionuse
Xml.asAttributeSet(XmlPullParser)instead. Not supported inResourcesMode.Mode.NATIVEUseXml.asAttributeSet(XmlPullParser)instead.
-
Deprecated ClassesClassDescriptionNative Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.only works when used in conjunction with the deprecated
LooperMode.Mode.LEGACYmode. Consider using guava'sMoreExecutors.directExecutor()orPausedExecutorServiceorInlineExecutorService.UseMatrixCursorinstead.UseMatrixCursorinstead.use LooperMode.Mode.INSTRUMENTATION_TEST insteadDon't put more stuff here.This package is no longer maintained and will be removed in Robolectric 4.16.This package is no longer maintained and will be removed in Robolectric 4.16.This package is no longer maintained and will be removed in Robolectric 4.16.UseGnssStatus.Builderinstead where possible.AsyncTaskis deprecated in the Android SDK.AsyncTaskLoaderis deprecated in the Android SDK.useInputDeviceBuilder.AsyncTaskis deprecated in the Android SDK.AsyncTaskLoaderis deprecated in the Android SDK.run on Android APIs >= S, which allows the real Android mime type data to be usedAsyncTaskis deprecated in the Android SDK.AsyncTaskLoaderis deprecated in the Android SDK.UseRangingResultBuilderinstead.UseRangingResultBuilderinstead.Scheduler APIs only function when using LooperMode.LEGACY. Switch to LooperMode.PAUSED and useShadowLooperAPIs instead.
-
Deprecated FieldsFieldDescriptionNot currently supported or used.Not currently supported or used.Please use {#getApplication} instead. Accessing this field directly is inherently incompatible with
LazyApplicationand Robolectric makes no guarantees if a test *modifies* this field during execution.UseRuntimeEnvironment.getApplication()instead. Note that unlike the alternative, this field is inherently incompatible withLazyApplication. This field may be removed in a later releaseUseShadowTelecomManager.CallRecord.extrasinstead.
-
Deprecated MethodsMethodDescriptionThe config change should be calculated internally by the activity controller based on the previous configuration, use
ActivityController.configurationChange(Configuration, DisplayMetrics)instead.Use the appropriate builder inRobolectricinstead.This method will be removed in Robolectric 3.6.
If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureConfigure asset directory via your build system; see Build System IntegrationConfigure libraries via your build system; see Build System IntegrationConfigure package name via your build system; see Build System IntegrationConfigure resource directory via your build system; see Build System IntegrationIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/To change your package name please override the applicationId in your build system. Changing package name here is broken as the package name will no longer match the package name encoded in the arsc resources file. If you are looking to simulate another application you can create another applications Context usingContext.createPackageContext(String, int). Note that you must add this package toShadowPackageManager.addPackage(android.content.pm.PackageInfo)first.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureUse theClassNameannotation or theImplementation.methodName()annotation parameter instead.UseNativeObjRegistry.register(Object)instead.UseNativeObjRegistry.unregister(long)instead.useRobolectric.getAttributeSetFromXml(int)insteadNative Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.TheSchedulerAPIs are designed for LEGACY Looper mode. UseShadowLooper.runToEndOfTasks()instead.TheSchedulerAPIs are designed for LEGACY Looper mode. UseShadowLooper.runToEndOfTasks()instead.TheSchedulerAPIs are designed for LEGACY Looper mode. It is strongly recommended to migrate tests to PAUSED Looper mode to avoid the need for this API.TheSchedulerAPIs are designed for LEGACY Looper mode. It is strongly recommended to migrate tests to PAUSED Looper mode to avoid the need for this API.useandroidx.test.core.app.ActivityScenarioProvide a service implementation ofGlobalConfigProviderinstead. This method will be removed in Robolectric 4.3.Do not use.obsolete do not useTheSchedulerAPIs are designed for LEGACY Looper mode. Prefer to migrate tests to PAUSED Looper mode to avoid the need for this API.TheSchedulerAPIs are designed for LEGACY Looper mode. Prefer to migrate tests to PAUSED Looper mode to avoid the need for this API.UseFakeHttp.getSentHttpRequestInfo(int)instead. This method will be removed in Robolectric 4.13.UseFakeHttp.getSentHttpRequest(int)instead. This method will be removed in Robolectric 4.13.UseActivityManager.getLockTaskModeState()instead.Prefer using overload withShadowActivityManager.ApplicationExitInfoBuilderdo not usePrefer to useShadowAlarmManager.setAutoSchedule(boolean)in combination with incrementing time to actually run alarms and test their side-effects.UseShadowAlertDialog.getLatestAlertDialog()instead.UseShadowDialog.getLatestDialog()instead.UseShadowPopupMenu.getLatestPopupMenu()instead.use PackageManager.queryBroadcastReceivers insteaduse PackageManager.queryBroadcastReceivers insteadThis is only for LEGACY Looper mode. Use PAUSED Looper mode instead.Do not depend on this method to override services as it will be removed in a future update. The preferred method is use the shadow of the corresponding service.Avoid use.use ShadowBitmap#getCreatedFromResId() instead.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.use real BluetoothLeAdvertiser insteadUse theLooperMode.Mode.PAUSEDlooper andShadowChoreographer.getFrameDelay()to configure the frame delay.useShadowChoreographer.getNextVsyncTimeNanos()insteadUse theLooperMode.Mode.PAUSEDlooper andShadowChoreographer.setFrameDelay(Duration)to configure the frame delay.Use theLooperMode.Mode.PAUSEDlooper instead.Use theLooperMode.Mode.PAUSEDlooper andShadowChoreographer.setPaused(boolean)andShadowChoreographer.setFrameDelay(Duration)to configure the vsync event behavior.implementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadUseRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor instead.UseRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor instead.UseRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor instead.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.UseRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor instead.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri). Instead, useRobolectric.setupContentProvider(Class, String)to install a test-specific ContentProvider that can return any Cursor.UseShadowCrossProfileApps.peekNextStartedActivity()instead.This behavior is deprecated and will be removed in Robolectric 4.13.This behavior is deprecated and will be removed in Robolectric 4.13.This behavior is deprecated and will be removed in Robolectric 3.7.This method is deprecated and will be removed in Robolectric 4.13.useContextCompat.getDrawable(context, resourceId)useShadowFingerprintManager.setDefaultFingerprints(int)instead.Please add calls by adding a Call usingInCallService.InCallServiceBinder.Please remove calls by invokingCall.disconnect().useInputDeviceBuilder.useInputDeviceBuilder.useInputDeviceBuilder.useInputDeviceBuilder.Use aHandlerinstance to post to a looper.Use aHandlerinstance to post to a looper.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)and test the results of those listeners being invoked.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)and test the results of those listeners being invoked.Do not test pending intents, instead useShadowLocationManager.simulateLocation(Location)and test the results of those pending intent being invoked.Do not test pending intents, instead useShadowLocationManager.simulateLocation(Location)and test the results of those pending intent being invoked.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)and test the results of those listeners being invoked.UseShadowLocationManager.simulateGnssAntennaInfo(List)instead.UseShadowLocationManager.simulateGnssStatus(GnssStatus)instead.UseShadowLocationManager.simulateLocation(Location)to update the last location for a provider.UseshadowOf({@link Looper#getMainLooper()})instead.Use aHandlerinstance to post to a looper.Use aHandlerinstance to post to a looper.useMotionEvent.obtain()orandroidx.test.core.view.MotionEventBuilderto create a MotionEvent with desired data.useMotionEvent.obtain()orMotionEventBuilderto create a MotionEvent with desired datauseMotionEvent.obtain()orandroidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)to create a MotionEvent with desired data.UseShadowPackageManager.installPackage(PackageInfo)instead.useShadowPackageManager.addIntentFilterForComponent(android.content.ComponentName, android.content.IntentFilter, java.util.Map<android.content.ComponentName, java.util.List<android.content.IntentFilter>>)instead and if the component doesn't exist add it using any ofShadowPackageManager.installPackage(android.content.pm.PackageInfo),ShadowPackageManager.addOrUpdateActivity(android.content.pm.ActivityInfo),ShadowPackageManager.addActivityIfNotPresent(android.content.ComponentName)or their counterparts for other types of components.see the note onShadowPackageManager.addResolveInfoForIntent(Intent, ResolveInfo).see the note onShadowPackageManager.addResolveInfoForIntent(Intent, ResolveInfo).It is recommended to switch to androidx's AsyncTaskLoader, which provides an overridable getExecutor method.this method only exists to accommodate legacy tests with preexisting issues. Silently discarding exceptions is not recommended, and can lead to deadlocks.preferShadowPendingIntent.isActivity()which was added toPendingIntentin API 31 (Android S).preferShadowPendingIntent.isBroadcast()which was added toPendingIntentin API 31 (Android S).preferShadowPendingIntent.isForegroundService()which was added toPendingIntentin API 31 (Android S).preferShadowPendingIntent.isService()which was added toPendingIntentin API 31 (Android S).PreferShadowPowerManager.turnScreenOn(boolean)instead.UseShadowPowerManager.turnScreenOn(boolean)instead.use ScanResult() insteaduse ScanResult() insteadUseShadowSensor.newInstance(int)to construct yourSensorand add to theSensorManagerusingShadowSensorManager.addSensor(Sensor)instead. This method will be removed at some point allowing us to use more of the realSensorManagercode.Use{@link SensorEventBuilder#newBuilder()}instead.Use{@link SensorEventBuilder#newBuilder()}instead.Use{@link SensorEventBuilder#newBuilder()}instead.Don't call this method directly; instead, useSystem.nanoTime().API deprecated since Q, for testing, use setDefaultDialerPackage insteadAvoid using.Avoid using.for resetAllSimCountryIsosuse resetAllSimStates()TelephonyManager.getNetworkType()was replaced withTelephonyManager.getDataNetworkType()in Android N, and has been deprecated in Android R. Useinstead.preferShadowUsbDeviceConnection.getOutgoingDataStream(), which allows callers to know how much data has been read and when theUsbDeviceConnectioncloses.use either addUser() or addProfile()useShadowUserManager.setUserSwitchability(int)insteadUseShadowUserManager.addUser(int, String, int)to create a demo user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)to create a guest user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)to create a linked user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)to create a primary user instead of changing default user flags.useShadowUserManager.addUser(int, String, int)insteadUseShadowUserManager.addUser(int, String, int)to create a system user instead of changing default user flags.When possible, please use the real Android framework APIUserManager#setUserRestriction().- Please use Espresso for View interactions.Please use Espresso for view interactions- Please useandroidx.test.espresso.util.HumanReadables#describe(View)- Please useandroidx.test.espresso.util.HumanReadables#describe(View)- Please useandroidx.test.espresso.util.HumanReadables#describe(View)- Please useandroidx.test.espresso.util.HumanReadables#describe(View)Do not depend on this method as it will be removed in a future update. The preferred method is to populate a fake web history to use for going back.This is no longer set on T+ due to MEP as a single eUICC can have more than one ICCID tied to it. It is instead set viaUiccPortInfo.UseUiccCardInfoBuilder.setPhysicalSlotIndex(int)for Android T+ instead.
-
Deprecated ConstructorsConstructorDescription
-
Deprecated Enum ConstantsEnum ConstantDescriptionuse LooperMode.PAUSEDThis mode is obsolete and will be removed soon.LEGACY mode is inaccurate, has known bugs and will be removed in a future release.REALISTIC is the default mode and does not need to be stated explicitly.
-
Deprecated Annotation Type ElementsAnnotation Type ElementDescriptionIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/To change your package name please override the applicationId in your build system. Changing package name here is broken as the package name will no longer match the package name encoded in the arsc resources file. If you are looking to simulate another application you can create another applications Context using
Context.createPackageContext(String, int). Note that you must add this package toShadowPackageManager.addPackage(android.content.pm.PackageInfo)first.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureUse theClassNameannotation or theImplementation.methodName()annotation parameter instead.