ADB (Android Debug Bridge) is an invaluable tool for developers, testers and Android enthusiasts alike. It allows you to interact with your Android device from a computer, opening new possibilities for application development and usability improvement. Explore ADB commands for android device manipulation in this blog.  

Android enthusiasts, developers and testers find ADB to be of great utility. It provides several features essential for managing devices and developing apps. 

ADB uses a command-line interface (CLI) to function. This implies that instead of interacting with it through a graphical user interface (GUI), you do it by typing instructions into a terminal or command prompt. 

ADB establishes a connection between your Android smartphone and PC. You can use your computer to control your gadget using this connection and use ADB Commands for Android Device interaction. 

Below are few of the benefits of using the ADB commands for Android Device Control

  • The tool makes it possible to do a variety of interactions with your Android device, which can be useful for both everyday use, development and testing. 
  • By enabling fast access to a device from a development environment, ADB helps developers to build and testers to test applications more efficiently. 
  • By providing access to more complex system capabilities, ADB can assist users in personalizing their devices or troubleshooting problems. 
  • ADB allows you to install apps straight from your development environment onto the device, saving you the trouble of manually moving them there. With the ability to perform diagnostic commands and retrieve error logs, it also aids in troubleshooting applications. 
  • System logs (logcat), which are essential for debugging apps and comprehending system events, can be retrieved by ADB. 
  • When you need to remotely manage a device or perform automated testing, it can mimic human activities like key presses and touch events. 

We’ll go over the most crucial ADB commands in this tutorial, along with their advantages and uses and explore ADB command for Android Device.

But before you start using the ADB commands to manipulate the Android device, you’ll first need to set up your device and computer to enable communication. 
 
Please refer to the Step 7 of the blog by Ajay Salunkhe on How to configure Windows Desktop for Android App Automation using Appium? 

Explore Following ADB Commands to manipulate Android Device

ADB Commands as below

Device Connectivity

Getting comprehensive details on your connected device is one of the most basic things you can do with ADB. For developers and testers who must comprehend the context in which their apps are operating, this is essential which can be achieved by executing the subsequent ADB command: 

This command displays a list of every device that is either networked or USB-connected to your computer. It provides a list of device serial numbers and their status, which can be  

1. “unauthorized” (meaning the device is connected but not authorized for ADB communication),  

2. “offline” (meaning the device is connected but not ready for commands), or  

3. “device” (meaning the device is connected and ready for commands). Making sure your device is correctly connected and prepared to communicate with ADB starts with doing this. 

Device Information

It is critical to understand the characteristics of your Android device. The following is a straightforward shell command that provides detailed information about the currently connected device. 

This command provides a list of exclusive device properties, including the phone number in store memory, the handle number for GSM radio standard communications, the operating system version, the device model, hardware details, and even kernel panics, if necessary. You can think of it as an inside perspective, opening a revealing window that can help identify problems and combine them with public report papers on security bugs to quickly ensure compatibility. 

Battery Power

Battery management is a crucial part of the app development and testing process. You can simulate different battery conditions and examine how your program behaves in response by setting the battery level using adb shell dumpsys. 

This command sets the battery level to 100%, but you can alter it to any percentage you wish. This is quite handy for evaluating your app’s response to low battery conditions, power saving settings, and charging state.

Bluetooth Enable

Many applications rely on Bluetooth capability, particularly those involving IoT devices, wearables, and music streaming. Use the following command to see if Bluetooth is enabled: 

A ‘1’ in the terminal response indicates Bluetooth is enabled, whereas a ‘0’ indicates Bluetooth is turned off. 

To turn on Bluetooth, use 

To turn off Bluetooth: 

Using these commands involves significantly less hardware labor when testing the Bluetooth functionality of your own software.

WiFi Control

Many apps require a Wi-Fi connection. To control the Wi-Fi status on your device, enter the following information: 

– Enable Wi-Fi: 

– Disable Wi-Fi: 

This is particularly handy when evaluating how your app functions without internet connectivity and providing different network situation simulations. 

Airplane Mode

When in airplane mode, all wireless connections are cut off, including Bluetooth, cellular, and Wi-Fi. You can use this to test the offline functionality of your app. Use these commands to switch between Airplane mode ON and Off: 

To enable Airplane mode: 

To disable Airplane mode: 

These commands help you test your app’s behavior in various connectivity scenarios.

Installing an App

Deploying your app to a physical device is a crucial step in development. To install an APK file on your device, use: 

Replace the ‘path-to-apk-file’ with the location of your APK file. This command simplifies the installation process across multiple devices, ensuring consistency.

Putting an App in the Background

Testing how your app behaves when sent to the background and brought back to the foreground is essential for a smooth user experience. To put an app in the background, use: 

The first command simulates pressing the home button, sending the app to the background. The second command brings up the recent apps screen, allowing you to simulate app switching.

Relaunching an App

To relaunch an app, use the `monkey` tool, which sends random events to the system. This is useful for stress testing and ensuring your app can handle unexpected inputs: 

Replace ` app-package ` with your app’s package name. This command launches the specified app, helping you automate the process of starting your app from a clean state.

Uninstalling an App

To uninstall an app from your device, use: 

Replace ` app-package` with the package name of the app you want to uninstall. This command is useful for cleaning up after tests and ensuring no residual data remains on the device.

Making a Call

For apps that interact with the phone’s calling capabilities, being able to initiate calls programmatically is important. To initiate a call from your device, use: 

Replace `1231231234` with the phone number you want to call. This command is useful for testing call-related features and interactions.

Rebooting the Device

Sometimes, a fresh start is needed. To reboot your device, simply use: 

This command restarts your device, ensuring it is in a clean state before starting tests or after making significant changes. 

Conclusion

These ADB instructions are but a sample of what may be accomplished using ADB by developers and testers. They undoubtedly offer a great deal of assistance with your work, including a better way to manage and debug native applications on your device and steps toward automation. These commands can be used in conjunction with your development and testing workflow to improve efficiency and ensure that, for example, an app’s behavior at various signal strengths is tested instantly. This eliminates the need for hours-long testing, which is particularly useful when a developer wants to upgrade or downgrade firmware based on how it will affect performance over varying time periods. This tool couldn’t be more powerful!  

Whether you’re a seasoned developer, tester or just starting out, ADB is the only tool you need with its many helpful commands that can handle anything from making the screen as bright or obscure as you like to completely changing the way Android can be used.  

Gaining control of these ADB commands will benefit you in a variety of testing and development situations, allowing your app to provide a seamless and enjoyable user experience. Thus, give them a go! I hope that learning about these commands will add a little bit of fun to your Android development and testing experience!  

Click here to read more blogs like this and learn new tricks and techniques of software testing.

1