Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Android Programming Day 1 25 best Android Apps http://www.youtube.com/watch?v=mLHqAMBQ Lzo&feature=fvwrel Java…a blast from the past • Android development language is Java • Java originally built as a cross platform language • Java should work on tv’s, music systems, etc. • The hardware abstraction problem remained • 2009 - 2012: Finally something like the purpose Java was developed for is happening through Android Day 1 Then and now • Android Inc bought by Google in 2005 • 2007 Open Handset Alliance • 2008 – 2010 Android becomes dominant mobile platform • 2011 Games, Tablets • 2012 Other devices (home entertainment) Android versions • • • • • 2.3 Gingerbread 3 Honeycomb (API 13) 4 Ice Cream Sandwich (API 14) 5 JellyBean developer.android.com The Android Stack The Stack – bottom layer • Linux Kernel – – – – – Not Linux Hardware abstraction layer Memory management Process management Networking • Why Linux? Driver model well known…can make it work on different chipsets • Linux kernel is secure • The adb shell command opens Linux shell Native Libraries • Pieces borrowed from other open source projects • Bionic, a fast and small c library, but under a lgpl licence • SQLite Dalvik • Android’s replacement for the Java Virtual Machine • Java VM owned by Oracle…licencing • Easier on the battery • Cooling effect • CPU capabilities • JVM…finds class file on disk…loads into RAM • Mobile…no disk….so no need to load into RAM Java VM • A Java virtual machine is a program which executes certain other programs, namely those containing Java bytecode instructions. JVMs are most often implemented to run on an existing operating system, but can also be implemented to run directly on hardware. A JVM provides an environment in which Java bytecode can be executed, enabling such features as automated exception handling, which provides root-cause debugging information for every software error (exception), independent of the source code. A JVM is distributed along with a set of standard class libraries that implement the Java application programming interface (API). These libraries, bundled together with the JVM, form the Java Runtime Environment (JRE). Java vs Dalvik Application Framework • The rich set of system services wrapped in an intuitive Java API • This is the environment/ecosystem that you as a developer will tap into when writing Android apps • Location / Web / telephony / Wifi / Bluetooth / notifocations / media / cameras / etc. Applications • • • • Dalvik executable (Java) + Resources = APK Code + everything else = APK Native libraries? Must be signed Markets • • • • • Google Playstore Amazon Android Market Samsung Store Many small stores now emerging Other emerging Market Questions about stack? Installing Android • Android SDK • Eclipse (Helios / Indigo / Juno…) Android SDK • Folder (android-sdk) – Tools – Platform tools • adb • SDK Manager – Install the platform you are going to use Add Android Tools to Eclipse • Help > Install new software > • ADT Plugin - http://dlssl.google.com/android/eclipse/ • Windows > Preferences > Android > SDK Location Hello World! • New Android Project • Select target – which platform are you targeting? JAVA CODE RESOURCES MANIFEST Resources • Specific folders and files • You cannot create your own folders in the “res” folder • Use the system to create new resource folders and files when needed • Strict naming convention AndroidManifest.xml • Used during the installation of your app • Example… • How to define an activity in your AndroidManifest.xml file? – Look at this in detail when working through xml example. Strings.xml What about adding another language string.xml file > New > Android XML file > strings.xml > Qualify Activity_main.xml • Screen layout view Resources • Summarized in R.java • R.java is the glue between your java files (src) and your resources (res) • Do not look into it, or modify it!! • Let’s just have a quick look at R.java How do we use R to specify resources? How to run our App? • AVD: Android Virtual Devices – Emulator – Emulator button in Eclipse • Running on actual Android device – Windows >> Kies – Androidscreencast.jnpl – Can save you lots of time!! • Build Automatically must be activated – Project > build automatically Looking at the files • How is the APK file built? • Classes.dex + resources.ap_ = HelloWorld.apk • This happens every time you build • Look at these files in workspace folder now. How to sign • Keytool part of JDK… • http://developer.android.com/tools/publishin g/app-signing.html • http://developer.android.com/tools/publishin g/preparing.html • Right-click on project – Android tools – Export signed application package Command line – keystore gen keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore my-releasekey.keystore my_application.apk alias_name zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk DDMS perspective • Windows > Open perspective • DDMS – File Explorer – Emulator or device must be running… – Check file structure (eg.look at system folder) Main Building Blocks Activities • An activity represents a screen or a window • Main activity • Other activities Activity lifecycle • Activities have a well-defined lifecycle. The Android OS manages your activity by changing its state. When to start/stop processes • Expensive processes should not run in an Activity (window) while it is not visible – this uses unnecesary memory and cpu • Start expensive processes (GPS, data send/receive) in the onResume() method, and stop them in onPause() • This way they never run in an Stopped Activity (window) Intents – joining activities (screens) • Intents represent events or actions