This method can be used to know whether activity instance creation should be intercepted or not
for a particular activity in response to a given intent.
This method can be used to know whether activity instance creation should be intercepted or not
for a particular activity in response to a given intent.
Parameters
classLoader
ClassLoader: The ClassLoader with which to instantiate the object
className
String: The name of the class implementing the Activity object
intent
Intent: The Intent object that specified the activity class being instantiated.
Returns
boolean
true if activity with className should be intercepted, otherwise false.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# InterceptingActivityFactory\n\nSummary: [Methods](#pubmethods) \\| [\\[Expand All\\]](#) \n\nInterceptingActivityFactory\n===========================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\n\ninterface\nInterceptingActivityFactory\n`\n\n\n`\n\n\n`\n\n|----------------------------------------------------------------------|\n| android.support.test.runner.intercepting.InterceptingActivityFactory |\n\n|---|---|\n| Known Indirect Subclasses [SingleActivityFactory](/reference/android/support/test/runner/intercepting/SingleActivityFactory)\\\u003cT extends [Activity](https://developer.android.com/reference/android/app/Activity.html)\\\u003e |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [SingleActivityFactory](/reference/android/support/test/runner/intercepting/SingleActivityFactory)\\\u003cT extends [Activity](https://developer.android.com/reference/android/app/Activity.html)\\\u003e | Abstract implementation of [InterceptingActivityFactory](/reference/android/support/test/runner/intercepting/InterceptingActivityFactory) which allows to intercept only one activity at a time. | ||\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nImplement this interface to provide custom implementation of Activity under test. It is used by\n[newActivity(ClassLoader, String, Intent)](/reference/android/support/test/runner/MonitoringInstrumentation#newActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent)) to create instance of the activity under test. Please see [interceptActivityUsing(InterceptingActivityFactory)](/reference/android/support/test/runner/MonitoringInstrumentation#interceptActivityUsing(android.support.test.runner.intercepting.InterceptingActivityFactory))\nfor more details.\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[Activity](https://developer.android.com/reference/android/app/Activity.html) | ` `[create](/reference/android/support/test/runner/intercepting/InterceptingActivityFactory#create(java.lang.ClassLoader, java.lang.String, android.content.Intent))`(`[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)` classLoader, `[String](https://developer.android.com/reference/java/lang/String.html)` className, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` This method can be used to provide activity instance while intercepting activity creation for a particular activity in response to a given intent. |\n| ` abstract boolean` | ` `[shouldIntercept](/reference/android/support/test/runner/intercepting/InterceptingActivityFactory#shouldIntercept(java.lang.ClassLoader, java.lang.String, android.content.Intent))`(`[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)` classLoader, `[String](https://developer.android.com/reference/java/lang/String.html)` className, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` This method can be used to know whether activity instance creation should be intercepted or not for a particular activity in response to a given intent. |\n\nPublic methods\n--------------\n\n### create\n\n```\nActivity create (ClassLoader classLoader, \n String className, \n Intent intent)\n```\n\nThis method can be used to provide activity instance while intercepting activity creation for a\nparticular activity in response to a given intent.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------|\n| `classLoader` | `ClassLoader`: The ClassLoader with which to instantiate the object \u003cbr /\u003e |\n| `className` | `String`: The name of the class implementing the Activity object \u003cbr /\u003e |\n| `intent` | `Intent`: The Intent object that specified the activity class being instantiated. \u003cbr /\u003e |\n\n| Returns ||\n|-------------------------------------------------------------------------------|------------------------------------------------|\n| [Activity](https://developer.android.com/reference/android/app/Activity.html) | The newly instantiated Activity object. \u003cbr /\u003e |\n\n### shouldIntercept\n\n```\nboolean shouldIntercept (ClassLoader classLoader, \n String className, \n Intent intent)\n```\n\nThis method can be used to know whether activity instance creation should be intercepted or not\nfor a particular activity in response to a given intent.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------|\n| `classLoader` | `ClassLoader`: The ClassLoader with which to instantiate the object \u003cbr /\u003e |\n| `className` | `String`: The name of the class implementing the Activity object \u003cbr /\u003e |\n| `intent` | `Intent`: The Intent object that specified the activity class being instantiated. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------------------|\n| `boolean` | true if activity with className should be intercepted, otherwise false. \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [InterceptingActivityFactory](/reference/android/support/test/runner/intercepting/InterceptingActivityFactory)\n-\n\n Classes\n -------\n\n - [SingleActivityFactory](/reference/android/support/test/runner/intercepting/SingleActivityFactory)"]]