- SL4A Tutorial
- SL4A - Home
- SL4A - Android Overview
- SL4A - Android Architecture
- SL4A - Scripting Layer for Android
- SL4A - Architecture
- SL4A - Python Library
- SL4A - Development Environment
- SL4A - Configuring Your Device
- SL4A - Navigating the Android SDK
- SL4A - Working with Eclipse
- SL4A - Exploring Android API
- SL4A - Building GUIs
- SL4A - Utilities using Python Facades
- SL4A - Background Script with Python
- SL4A - Packaging & Distributing
SL4A - Navigating the Android SDK
A software development kit that enables developers to create applications for the Android platform. The Android SDK includes sample projects with source code, development tools, an emulator, and required libraries to build Android applications. This chapter discusses the Android SDK and ways to use it for developing the code targeted at SL4A.
The directory tree where you installed the Android SDK, contains a list of folders containing documentation, sample code and a number of tools. Navigating to the tools subdirectory reveals a number of executable files.
Discussed below are some important components within the Android SDK.
The Android SDK Manager separates the SDK tools, platforms, and other components into packages for easy access and management. The SDK can be configured to check for new or updated SDK packages and add-on tools.
By default, Android Studio does not check for Android SDK updates. To enable automatic Android SDK checking −
Step 1 − Choose File → Settings → Appearance & Behavior → System Settings → Updates.
Step 2 − Check the Automatically check updates for Android SDK checkbox and select an update channel.
Step 3 − Click OK or Apply to enable the update checking.
The SDK Update Sites tab displays the sites that Android Studio checks for Android SDK and third-party updates. You can add other sites that host their own Android SDK addons, then download the SDK add-ons from those sites.
The AVD Manager provides a graphical user interface in which you can create and manage Android Virtual Devices (AVDs), which are required by the Android Emulator. An Android Virtual Device (AVD) consists of a number of files including configuration and virtual storage required by the emulator. You can create as many AVDs as you want for simulating different devices.
The following steps can be used to create an AVD in Eclipse −
Step 1 − Select Window → AVD Manager.
Step 2 − Click New.
Step 3 − Type the name of the AVD, choose the target and specify values for the other features.
Step 4 − Click Create AVD.
For devices with keyboard, there is a standard set of mappings from the host keyboard to actions on the device. The default Emulator key mappings are −
|Emulator Key||Mapping on Host Device|
|CHANGE_LAYOUT_NEXT||Keypad_9, Ctrl+ F12|
You can change these settings by editing the default.keyset file in the .android subdirectory.
Android Debug Bridge
ADB, Android Debug Bridge, is a command-line utility included with Google’s Android SDK. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more.
If you have an emulator running and a real device connected, you must specify where you want the ADB commands to a real device, use the option − d and for the emulator, use –e. Following is the list of flags and commands for ADB.
|S.No.||ADB flags & Description|
Directs device to the only connected USB device; returns an error if more than one USB device is connected.
Directs command to the only running emulator; returns an error if more than one emulator is running.
Directs command the USB device or emulator with the given serial number.
List all connected devices
Connect to a device via TCP/IP
Disconnect from a TCP/IP device
|S.No.||ADB commands & Description|
adb push <local> <remote>
Copy file/dir to device
adb pull <remote> [<local>]
Copy file/dir from device
adb sync [<directory>]
If <directory>is not specified, both /system and /data partitions will be updated. If it is “system” or “data”, only the corresponding partition is updated.
Run remote shell interactively
adb emu <command>
Run emulator console command
View device log
adb forward <local> <remote>
Forward socket connections
adb install [-l] [-r] [-s] <file>
Push this package file to device and install it. (-l forward lock the app)
(-r reinstall the app, keeping its data)
(-s install on SD card instead of internal storage)
adb uninstall [-k] <package>
Remove this app package from the device. -k means keep the data and cache directories
Return all information from the device that should be included in the bug report.
Show this help message
Show version number
A shell is a program that listens to keyboard input from the user and performs actions as directed by the user. The adb shell command provides Unix to send shell commands to an emulator or a connected device and display the results. It can also be used to launch an interactive shell locally.
To issue a single command without entering a remote shell, use the shell command like this −
adb [-d|-e|-s <serialNumber>] shell <shell_command>
Or to enter a remote shell on an emulator/device −
adb [-d|-e|-s <serialNumber>] shell
When you are ready to exit the remote shell, press CTRL+D or type EXIT.
Dalvik Debug Monitor Service
Android ships a debugging tool, Dalvik Debug Monitor Service (DDMS). This tool provides additional services such as port-forwarding services, screen capture on device, incoming call and SMS spoofing etc.
When DDMS starts, it connects to adb. A VM monitoring service is created between adb and DDMS, when a device is connected. This service notifies DDMS when a VM on the device is started or terminated.
Once the VM starts running, its process id is sent to the DDMS via adb and the adb daemon opens a connection to the VM’s debugger. DDMS can now talk to the VM using a custom wire protocol.
Kickstart Your Career
Get certified by completing the courseGet Started