Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#pubctors) \| [Methods](https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#inhmethods)

# SingleLaunchActivityTestCase

*** ** * ** ***

` public abstract class SingleLaunchActivityTestCase `   
` ` ` extends https://developer.android.com/reference/android/test/InstrumentationTestCase ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase) ||
|   | ↳ | android.test.SingleLaunchActivityTestCase\<T extends [android.app.Activity](https://developer.android.com/reference/android/app/Activity)\> |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 24.**   

Use [ActivityTestRule](https://developer.android.com/reference/android/support/test/rule/ActivityTestRule) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).

If you would like to test a single activity with an `https://developer.android.com/reference/android/test/InstrumentationTestCase`, this provides some of the boiler plate to launch and finish the activity in `https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#setUp()` and `https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#tearDown()`. This launches the activity only once for the entire class instead of doing it in every setup / teardown call.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#SingleLaunchActivityTestCase(java.lang.String,%20java.lang.Class<T>)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityClass) ` **NOTE:** The parameter *pkg* must refer to the package identifier of the package hosting the activity to be launched, which is specified in the AndroidManifest.xml file. |

| ### Public methods ||
|---|---|
| ` T` | ` https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#getActivity()() ` |
| ` void` | ` https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#testActivityTestCaseSetUpProperly()() ` |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#setUp()() ` |
| ` void` | ` https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase#tearDown()() ` Make sure all resources are cleaned up and garbage collected before moving on to the next test. |

### Inherited methods

From class ` https://developer.android.com/reference/android/test/InstrumentationTestCase ` ` https://developer.android.com/reference/android/app/Instrumentation` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#getInstrumentation()() `

Inheritors can access the instrumentation using this.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInsrumentation(android.app.Instrumentation)(https://developer.android.com/reference/android/app/Instrumentation instrumentation) `

*This method was deprecated in API level 15. Incorrect spelling, use `https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInstrumentation(android.app.Instrumentation)` instead.*
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInstrumentation(android.app.Instrumentation)(https://developer.android.com/reference/android/app/Instrumentation instrumentation) `

Injects instrumentation into this test case.
` final <T extends https://developer.android.com/reference/android/app/Activity> T` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#launchActivity(java.lang.String,%20java.lang.Class<T>,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityCls, https://developer.android.com/reference/android/os/Bundle extras) `

Utility method for launching an activity.
` final <T extends https://developer.android.com/reference/android/app/Activity> T` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#launchActivityWithIntent(java.lang.String,%20java.lang.Class<T>,%20android.content.Intent)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityCls, https://developer.android.com/reference/android/content/Intent intent) `

Utility method for launching an activity with a specific Intent.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#runTest()() `

Runs the current unit test.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#runTestOnUiThread(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable r) `

Helper for running portions of a test on the UI thread.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendKeys(int[])(int... keys) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendKeys(java.lang.String)(https://developer.android.com/reference/java/lang/String keysSequence) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendRepeatedKeys(int[])(int... keys) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#tearDown()() `

Make sure all resources are cleaned up and garbage collected before moving on to the next test.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### SingleLaunchActivityTestCase

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SingleLaunchActivityTestCase (String pkg, 
                Class<T> activityClass)
```

**NOTE:** The parameter *pkg* must refer to the package identifier of the package hosting the activity to be launched, which is specified in the AndroidManifest.xml file. This is not necessarily the same as the java package name.

<br />

| Parameters ||
|---|---|
| `pkg` | `String`: The package hosting the activity to be launched. <br /> |
| `activityClass` | `Class`: The activity to test. <br /> |

## Public methods

### getActivity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T getActivity ()
```

<br />

<br />

| Returns ||
|---|---|
| `T` | <br /> |

### testActivityTestCaseSetUpProperly

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void testActivityTestCaseSetUpProperly ()
```

<br />

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |

## Protected methods

### setUp

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void setUp ()
```

<br />

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |

### tearDown

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void tearDown ()
```

Make sure all resources are cleaned up and garbage collected before moving on to the next test. Subclasses that override this method should make sure they call super.tearDown() at the end of the overriding method.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |