22 April 2024 Leave a comment Tech-Help
Android Debug Bridge (ADB) is a versatile command-line tool that allows developers to communicate with a device. A common task that arises is the need to start an application on your Android device from a development machine. This article will guide you through the process of using ADB to send intents to start applications.
Starting an Application with ADB
To start an application using ADB, you’ll need to use the am
(Activity Manager) command. Here’s the basic syntax:
adb shell am start -n com.package.name/com.package.name.ActivityName
This command specifies the package name and the activity name you want to launch. For example, if you want to start the main activity of an app with the package name com.example.app
, you would use:
adb shell am start -n com.example.app/com.example.app.MainActivity
Intent Actions
Sometimes, you might want to start an activity with a specific action. This can be achieved by adding the -a
flag to specify an action:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName
Alternative Method: Using Monkey Tool
Another method to start an application is by using the monkey tool, which is primarily used for generating pseudo-random streams of user events. However, it can also be used to launch an app:
adb shell monkey -p your.app.package.name -c android.intent.category.LAUNCHER 1
The -p
flag specifies the package name, while the -c
flag specifies the intent category. The number 1
at the end of the command indicates that only a single event is sent to start the app.
Conclusion
Starting an Android application via ADB can be straightforward, using the correct package and activity names. Remember that you can always retrieve a list of installed packages on your device with the command adb shell pm list packages
, which can be helpful when you need to find the package name of an app.
Streamline Your Testing with Repeato
While ADB provides powerful ways to interact with your app during development, when it comes to testing, you might seek a more streamlined and automated approach. This is where Repeato comes into play.
Repeato is a No-code test automation tool that excels in creating, running, and maintaining automated tests for iOS and Android applications. Its intuitive interface and reliance on computer vision and AI make it incredibly easy to set up and use, regardless of the app framework you’re working with, including React Native, Flutter, Unity, and others.
Moreover, Repeato allows you to execute ADB commands via “script steps,” integrating seamlessly into your existing workflow. Whether you’re dealing with a complex CI/CD pipeline or just want to ensure your app’s quality with efficient and reliable automated testing, Repeato can significantly enhance your process.
Learn more about how Repeato can assist with your app testing needs by exploring our mobile UI testing tools and see how it compares with other solutions such as Espresso or Appium.