Friday 12 August 2016

Android ADB Commands, Tricks & Hacks

Android ADB Commands & Tricks

Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android device. It facilitates a variety of device actions, such as installing and debugging apps, and it provides access a Unix shell that you can use to run a variety of commands on an emulator or connected device. It is a client-server program that includes three components:
  • A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.
  • A daemon, which runs commands on a device. The daemon runs as a background process on each emulator or device instance.
  • A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.
read more

adb devices 

list all the devices which is connected with the system.

adb -e shell

open emulator shell

adb -d shell

open device shell

what if we have more than 2 emulators or devices

adb -s <serial no> shell

use serial number to open device shell

adb  shell pm list packages 

list all the installed app package name.

but how to get debugable apps package name

adb jdwp
list all debugable apps process id

adb shell cat /proc/<process id>/cmdline 
              or  
adb shell cat /proc/<process id>/comm  

use process id to get the package name

adb shell ps <process id>

use process id to know the process information

you can fire all those cmd in adb shell also

$adb shell

to enter in android shell

$cat /proc/<process id>/cmdline 
               or  
$cat /proc/<process id>/comm
use process id to get the package name

$ps <process id>

use process id to know the process information

some more interesting commands

Dial Number: 

adb shell service call phone 1 s16 "+9191919191" 

here phone is a service, 1 is service code & s16 is parameter type and "+9191919191" is a parameter value.

Call Number:

adb shell service call phone 2 s16 "" s16 "+9191919191"

here phone is a service, 2 is service code & s16 is a 1st parameter type but no value & s16 is a 2nd parameter type and "+9191919191" is a parameter value.

Kill-APP:

adb  shell am force-stop <package name> 

Start App

adb shell monkey -p <package name> -c android.intent.category.LAUNCHER 1

Pull Down StatusBar

adb shell service call statusbar 1

Pull Up StatusBar

adb shell service call statusbar 2

wakeup/Sleep device

adb shell input keyevent 26 

unlock device

adb shell input keyevent 82

others services

adb shell service list

 

 




 

No comments:

Post a Comment

Things after Kotlin Android Extensions

Things after Kotlin Android Extensions(KTX) I remembered in MVVM when I have to declare ViewModel, I initialize View Model like this. p...