Android ADB shell Command Device interaction

ADB Stands for Android Debug Bridge , ADB is a command line tool which lets you to communicate with emulator or any android device which is connected to your computer .

ADB command line tool utility is included in android SDK , so firstly you must install android SDK in your computer to work with ADB Command .

After Installing SDK ,for accessing ADB Command through command line you need to make android sdk tools available to systems environment variable


Lets See some of ADB Commands.

1. The adb devices command


The adb devices command on execution displays the number of  Android devices connected to your computer with name and id , this cmd is mainly used to make ensure the communication between your computer and android devices

Command
        adb devices


2. adb shell input text


The adb shell input text command is used for sending text from computer to android device , this command takes text as a parameter to it and passes it on android device which is in connected 

Note : Have focus on edittext ui component ,before executing this cmd , because the edittext ui component receives the text send by this command.

Command
            adb shell input text "yout_text_goes_here"

Here is an sample scenario of inputing text into edittext component

 adb shell input text "http://www.pavanh.com/p/android-tutorial.html"

adb shell input text


3. adb shell input swipe


The adb shell input swipe command is used for swiping on to android device , this command takes four parameter which are grouped into two forms ,specifes start and end co-ordinates.

         swipe start point co-ordinates  :  x1  y1
         swipe End Point  co-ordinates :  x2  y2

Command
             adb shell input swipe x1 y1 x2 y2

Here is an useful scenario of swipe command for opening and closing notification


Note : This command is tested with HTC Desire X Device , the co-ordinates may vary from device to device , make ensure you use co-ordinates points according to the one

 > Opening Notification

     adb shell input swipe 10 10 10 1000

adb shell input swipe

> Closing Notification

     adb shell input swipe 10 1000 10 10

adb shell input swipe


4. adb shell input tap


The adb shell input swipe command is used for tapping on to android device screen , this command takes two parameter which specifies the co-ordinate point for tappping on to the screen

Command
            adb shell input tap x1 y1

Here is an sample scenario of tapping on to application icon to open it

     adb shell input tap 200 300

adb shell input tap

7 comments:

maruti kutre said...

Nice one pavan..

Inderjeet said...

good work...I was not known with swipe especially

Maheswaran Murugan said...

Hi Pavan, first I say thanks for your valuable post. I need to send free sms from my android application using AT command or any other free sms gateway. Is it possible to send free sms from android application? if it is possible please guide me to implement it in my application. maheswaran.android87@gmail.com this is my mail ID. Please let me know immediately. Thanks.

shashank sharma said...

awesome...great

Ranjit Awati said...

Hi Pavan,Thank you for your valuable Post,it helped me a lot as i'm a fresher working on Android application Automation

ogonzuhnina said...

Hi, would you bother getting to the opensource Android screencast app and add these to the code, then there would be full blown remote controll app (mapping taps and swipes)
I have no idea about java code or compile :/

Rajendra Testing said...

I need to swipe down with three fingers at a time. How can I script for this gesture.

Post a Comment