Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Programming Day 1. 25 best Android Apps Lzo&feature=fvwrel.

Similar presentations


Presentation on theme: "Android Programming Day 1. 25 best Android Apps Lzo&feature=fvwrel."— Presentation transcript:

1 Android Programming Day 1

2 25 best Android Apps http://www.youtube.com/watch?v=mLHqAMBQ Lzo&feature=fvwrel

3 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

4 Day 1

5 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)

6 Android versions 2.3 Gingerbread 3 Honeycomb (API 13) 4 Ice Cream Sandwich (API 14) 5 JellyBean developer.android.com

7 The Android Stack

8 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

9 Native Libraries Pieces borrowed from other open source projects Bionic, a fast and small c library, but under a lgpl licence SQLite

10 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

11 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).operating systemautomated exception handlingexceptionset of standard class librariesapplication programming interfaceJRE

12 Java vs Dalvik

13 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.

14 Applications Dalvik executable (Java) + Resources = APK Code + everything else = APK Native libraries? Must be signed

15 Markets Google Playstore Amazon Android Market Samsung Store Many small stores now emerging Other emerging Market

16 Questions about stack?

17 Installing Android Android SDK Eclipse (Helios / Indigo / Juno…)

18 Android SDK Folder (android-sdk) – Tools – Platform tools adb SDK Manager – Install the platform you are going to use

19 Add Android Tools to Eclipse Help > Install new software > ADT Plugin - http://dl- ssl.google.com/android/eclipse/http://dl- ssl.google.com/android/eclipse/ Windows > Preferences > Android > SDK Location

20 Hello World! New Android Project Select target – which platform are you targeting?

21 JAVA CODE RESOURCES MANIFEST

22 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

23 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.

24 Strings.xml What about adding another language string.xml file > New > Android XML file > strings.xml > Qualify

25 Activity_main.xml Screen layout view

26 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

27 How do we use R to specify resources?

28 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

29 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.

30 How to sign Keytool part of JDK… http://developer.android.com/tools/publishin g/app-signing.html http://developer.android.com/tools/publishin g/app-signing.html http://developer.android.com/tools/publishin g/preparing.html http://developer.android.com/tools/publishin g/preparing.html Right-click on project – Android tools – Export signed application package

31 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-release- key.keystore my_application.apk alias_name zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

32 DDMS perspective Windows > Open perspective DDMS – File Explorer – Emulator or device must be running… – Check file structure (eg.look at system folder)

33 Main Building Blocks

34 Activities An activity represents a screen or a window Main activity Other activities

35 Activity lifecycle Activities have a well-defined lifecycle. The Android OS manages your activity by changing its state.

36

37 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)

38 Intents – joining activities (screens) Intents represent events or actions


Download ppt "Android Programming Day 1. 25 best Android Apps Lzo&feature=fvwrel."

Similar presentations


Ads by Google