launching-activities-with-activityscenario

Community

Launch Activities reliably with ActivityScenario

Authorskydoves
Version1.0.0
Installs0

System Documentation

What problem does it solve?

It solves flaky or failing Android instrumentation tests by showing the canonical, lifecycle-safe way to launch an Activity with ActivityScenario instead of deprecated ActivityTestRule, including correct threading, recreation, and teardown.

Core Features & Use Cases

  • Canonical ActivityScenario launch & lifecycle control: Covers ActivityScenario.launch, launch with Intent, launchActivityForResult, moveToState across CREATED/STARTED/RESUMED/DESTROYED, and proper closing behavior.
  • UI-thread safe interaction: Uses onActivity { } to mutate or read views/state without deadlocks and explains how to avoid calling scenario APIs from the main thread.
  • Configuration-change emulation: Uses recreate() to trigger state save/restore flows and explains why rememberSaveable/SavedStateHandle/onSaveInstanceState survive while plain remember does not.
  • Common migration traps: Clarifies the single canonical FQN for ActivityScenarioRule (androidx.test.ext.junit.rules.ActivityScenarioRule) and avoids the non-existent androidx.test.rule.ActivityScenarioRule confusion.

Quick Start

Use the launching-activities-with-activityscenario skill to show how to migrate from ActivityTestRule to ActivityScenarioRule and launch the Activity safely in an instrumentation test.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: launching-activities-with-activityscenario
Download link: https://github.com/skydoves/android-testing-skills/archive/main.zip#launching-activities-with-activityscenario

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.