Transcription
AN INTRODUCTION TO ANDROID DEVELOPMENTCS231M Alejandro Troccoli
OutlineOverview of the Android Operating SystemDevelopment toolsDeploying application packagesStep-by-step application development
The Android ecosystemAn open source platform for mobile, embedded and wearabledevicesGoogle is the principle maintainerOther companies contribute to the system.Each device manufacturer can customize Android to suite theirneeds
Android architectureUser applicationsUse Java framework and, optionally, native code.Android frameworkJava classes under com.androidNative framework layerUser mode C, C code – compiled to native platform or 32bitcompatibility mode on 64 bits.Linux Kernel (GPL license)C code – compiled to native platform (x86, arm, mips)
Android versioningPlaform version5.0 Lollipop4.4 KitKatFramework API levelSDK compatibilityEach platform version has an API levelNDK API levelAPI level for native out/dashboards/index.html
Browsing the Android SourceSource at:https://android.googlesource.com/Porting instructions (for system x.html
Reference to the framework APIscom.android ages.html
OutlineOverview of the Android Operating SystemDevelopment toolsDeploying application packagesStep-by-step application development
Tools for application developmentAndroid SDKProvides the Java framework classesCompiles to java bytecodeClass framework is updated with every OS releaseAndroid NDKC/C toolchain for compiling to machine codeAndroid platform toolsadb (android debug bridge) : runs and debugs apps from your dev machineAndroid developer toolsEclipse plug-in for AndroidAndroid studio (doesn’t yet fully support all NDK features)
Setup optionsTegra Android Development packInstall components manuallyUse a Linux virtual machine with the tools pre-installed.
Tegra Android Development Pack
Tegra Android Development PackRegister for an account up for Gameworks Registered Developer Program
NVIDIA Shield TabletClick 7 times to enable developer options
OutlineOverview of the Android Operating SystemDevelopment toolsDeploying application packagesStep-by-step application development
Application packages.apk files: compressed filesclass byte coderesources( icons, sounds, etc).Binary native filesAll .apks are signedDefault development key is created by SDK.When updating an application, signature are checked.
Installing an applicationFrom application distribution marketsGoogle PlayAmazon AppStoreFrom your local computer using adb
Enabling android debug bridge (adb)
Useful adb commands
OutlineOverview of the Android Operating SystemDevelopment toolsDeploying application packagesStep-by-step application development
Hello Android!In EclipseFile - New - AndroidApplication Project
Hello Android!
Hello Android!
Import an project from existing code
AndroidManifest.xmlPackage Name / versionRequired SDK and target SDKApplication/ActivitiesPermissions
Android ActivityProvides user android/app/Activity.htmlCallbacks for life-cycle managementonCreate()onResume()onPause()An application can have multiple activities.Needs one launcher activity
HelloAndroidActivity
HelloAndroidActivityUse onCreate() to create UI.
Launch!Add Activity to AndroidManifest.xml:
Launch! (take 2)
Launch with debugger
Launch (take 3!)
ViewsCan be composed in a tree hierarchy.The root View is the argument to setContentView
Creating a layout
Accessing layout elements from ActivtiyUse findViewByIdR.id.name corresponds tothe name given in the xmlfile
Event listeners (and logging, too)
LogcatWindow - Show View - Other - Android - Logcat
Creating a log file
Writing to the log file
Long running taskLong running tasks on the main thread can block the UIApp looks unresponsive
Use a separate Thread instead
Use Handlers to update UI
Add a Progress dialog
Summary
adb (android debug bridge) : runs and debugs apps from your dev machine Android developer tools Eclipse plug-in for Android Android studio (doesn’t yet fully support all NDK features) Setup options Tegra Android Development pack Install components manually Use a Linux virtual machine with the tools pre-installed. Tegra Android Development Pack. Tegra Android Development Pack