Finding the Launchable Activity Name of an Android Package Using ADB

Finding the Launchable Activity Name of an Android Package Using ADB

30 November 2024 Stephan Petzl Leave a comment Tech-Help

Determining the launchable activity name of an Android app package can be crucial for developers and testers alike. This task can be achieved using the Android Debug Bridge (ADB) without requiring root access on the device. In this article, we will guide you through a straightforward method to retrieve the launchable activity name using ADB commands.

Step-by-Step Guide

Using ADB Commands

If you are working with Android 7.0 or later, the following command provides a direct approach to finding the default launchable activity of an installed app:

adb shell "cmd package resolve-activity --brief com.example.package | tail -n 1"

This command will output the package name followed by the activity name, which is essential for launching the app programmatically or setting up automation scripts.

Alternate Method for Older Android Versions

For devices running versions prior to Android 7.0, use the following sequence of commands:

  • List all installed packages and their paths:
    adb shell pm list packages -f
  • Pull the APK file from the device:
    adb pull 
  • Use the aapt tool to extract information:
    aapt dump badging 

This method allows you to inspect the APK file and find the desired activity information manually.

Practical Example

Let’s say you have the package name com.google.android.calculator. Using the ADB command for Android 7.0 and above, you would execute:

adb shell "cmd package resolve-activity --brief com.google.android.calculator | tail -n 1"

The output might look like:

com.google.android.calculator/com.android.calculator2.Calculator

Enhancing Your Testing Workflow

Understanding how to resolve launchable activity names can significantly streamline your app testing and automation processes. For those looking to further enhance their testing capabilities, consider using Repeato, a no-code test automation tool designed for iOS and Android. Repeato leverages computer vision and AI, allowing you to create, run, and maintain automated tests efficiently. The tool integrates ADB, enabling precise execution of ADB commands via script steps, which can be particularly useful when testing app launch activities.

For more information on using ADB in your testing setup, explore our documentation.

Like this article? there’s more where that came from!