0% found this document useful (0 votes)
361 views4 pages

Adb Tutorials

Android

Uploaded by

chatenilesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
361 views4 pages

Adb Tutorials

Android

Uploaded by

chatenilesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Support free tutorials:

Using the Android Debug Bridge (adb) Tutorial


Lars Vogel
Version11.2
Copyright2009,2010,2011,2012,2013LarsVogel
28.10.2013
Revision History
Revision 0.1 - 11.2

04.07.2009 - 28.10.2013

bug fixing and enhancements

Using the adb tools with Android


ThistutorialdescribeshowtousetheadbtooltoaccessyourAndroiddeviceorAndroidvirtualdevice(AVD).

TableofContents
1. Android Debugging Bridge - adb
2. Shell access via adb
3. Copy files from and to your device
4. Uninstall an application via adb
5. Telnet your your Android device
6. Comand line tool dumpsys
6.1. adb dumpsys
6.2. Memory consumption overview with
dumpsys
6.3. Information about schedule tasks
7. Support free vogella tutorials
7.1. Thank you
7.2. Questions and Discussion
8. Links and Literature
8.1. Source Code
8.2. Android Resources
8.3. vogella Resources

Search Training Books Blog Shop Contact us


[Link] Tutorials

1. Android Debugging Bridge - adb


YoucanaccessyourAndroiddeviceviatheadbcommandonthecommandline..AnAndroidvirtualdevicecanbe
freelyaccessed,anormalAndroidphoneneedstogetrooted,[Link]
everythingonthisdevice.
Theadbtoolsislocatedinthe[android-sdks]/[Link]
pathtohavedirectaccesstothiscommand.

TheadballowsyoutosendcommandstoyourAndroiddevice,pullandpushfilestoit,givesshellaccesstothe
Androiddeviceandallowsyoutoreadinformationfromyourdevice,[Link]
followingchapterdescribetheusageofthecorrespondingcommands.
Ifyouhaveseveraldevicesrunningyoucanissuecommandstooneindividualdevice.
# Lists all devices
adb devices
#Result
List of devices attached
emulator-5554 attached
emulator-5555 attached
# Issue a command to a specific device
adb -s emulator-5554 shell

2. Shell access via adb


YoucangetshellaccesstoyourAndroiddeviceviathefollowingcommand.
adb shell

ThiswillconnectyoutoyourdeviceandgiveyouLinuxcommandlineaccesstotheunderlyingfilesystem,[Link],
rm,,cd,mkdir,[Link]"/data/data/package_of_your_app".

3. Copy files from and to your device


Youcancopyafilefromandtoyourdeviceviathefollowingcommands.
// assume the gesture file exists on your Android device
adb pull /sdcard/gestures ~/test
// now copy it back
adb push ~/test/gesture /sdcard/gestures2

4. Uninstall an application via adb


[Link]/appdirectory(cd/data/app)andsimply
deleteyourandroidapplication.
Youcanalsouninstallanappviaadbwiththepackagename.
adb uninstall <packagename>

5. Telnet your your Android device


[Link],e.g.
incomingcall,changethenetworkconnectivity,setyourcurrentgeocodes,[Link]"telnetlocalhost5554"to
[Link],usethequitorexitcommand.
Forexampletochangethepowersettingsofyourphone,toreceiveansmsandtogetanincomingcallmakethe
following.
# connects to device
telnet localhost 5554
# set the power level
power status full
power status charging
# make a call to the device
gsm call 012041293123
# send a sms to the device
sms send 12345 Will be home soon
# set the geo location
geo fix 48 51

FormoreinformationontheemulatorconsolepleaseseeEmulatorConsolemanual

6. Comand line tool dumpsys


6.1. adb dumpsys
Theadb dumpsyscommandallowsyoutoretaininformationabouttheAndroidsystemandtherunningapplications.
Togetcurrentlymemoryconsumptionofanapplicationyoucanusethefollowingcommand.
adb shell dumpsys meminfo <[Link]>

6.2. Memory consumption overview with dumpsys


Theadb shell [Link]
[Link] shell dumpsys meminfoinstead.

6.3. Information about schedule tasks


Tofindwhichalarmsarescheduledforyourapplication,usetheadb shell dumpsys alarmcommandandlookfor
[Link]:
RTC #6: Alarm{434a1234 type 1 [Link]}
type=1 whenElapsed=608198149 when=+12m13s122ms window=-1 repeatInterval=0 count=0
operation=PendingIntent{430cf612: PendingIntentRecord{*43bbf887* [Link] startS
ervice}}

Thisshowstheinfothatthealarmisscheduledforapprox.12minutes.
Tofindouttheinformationaboutthependingintent,runtheadb shell dumpsys activity intentscommandand
lookfortheIDofthePendingIntentRecord(inthisexample43bbf887):
* PendingIntentRecord{43bbf887 [Link] startService}
uid=10042 packageName=[Link] type=startService flags=0x0
requestIntent=act=MY_ACTION cmp=[Link]/.MyService (has extras)

7. Support free vogella tutorials


[Link]
[Link]
[Link]
typosandfactualerrors.

7.1. Thank you


Pleaseconsideracontributionifthisarticlehelpedyou.

7.2. Questions and Discussion


Ifyoufinderrorsinthistutorial,pleasenotifyme(seethetopofthepage).Pleasenotethatduetothehigh
volumeoffeedbackIreceive,[Link]
vogellaFAQasIdon'trespondtoquestionsalreadyansweredthere.

8. Links and Literature


8.1. Source Code
SourceCodeofExamples

8.2. Android Resources


AndroidIntroductionTutorial
AndroidListViewandListActivity
AndroidSQliteDatabase
AndroidWidgets
AndroidLiveWallpaper
AndroidServices
AndroidLocationAPIandGoogleMaps
AndroidIntents
AndroidandNetworking
AndroidHomepage
AndroidDeveloperHomepage
AndroidIssues/Bugs
AndroidGoogleGroups
AndroidLiveFolder

8.3. vogella Resources


vogellaTrainingAndroidandEclipseTrainingfromthevogellateam
AndroidTutorialIntroductiontoAndroidProgramming
GWTTutorialPrograminJava,compiletoJavaScriptandHTML
EclipseRCPTutorialCreatenativeapplicationsinJava
JUnitTutorialTestyourapplication
GitTutorialPutallyourfilesinadistributedversioncontrolsystem

You might also like