Android programming
This presentation is the property of its rightful owner.
Sponsored Links
1 / 38

Android Programming PowerPoint PPT Presentation


  • 110 Views
  • Uploaded on
  • Presentation posted in: General

Android Programming. Day 1. 25 best Android Apps. http://www.youtube.com/watch?v=mLHqAMBQLzo&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.

Download Presentation

Android Programming

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Android programming

Android Programming

Day 1


25 best android apps

25 best Android Apps

http://www.youtube.com/watch?v=mLHqAMBQLzo&feature=fvwrel


Java a blast from the past

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

Day 1


Then and now

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

Android versions

  • 2.3 Gingerbread

  • 3 Honeycomb (API 13)

  • 4 Ice Cream Sandwich (API 14)

  • 5 JellyBean

  • developer.android.com


The android stack

The Android Stack


The stack bottom layer

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

Native Libraries

  • Pieces borrowed from other open source projects

  • Bionic, a fast and small c library, but under a lgpl licence

  • SQLite


Dalvik

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

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

Java vs Dalvik


Application framework

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

Applications

  • Dalvik executable (Java) + Resources = APK

  • Code + everything else = APK

  • Native libraries?

  • Must be signed


Markets

Markets

  • Google Playstore

  • Amazon Android Market

  • Samsung Store

  • Many small stores now emerging

  • Other emerging Market


Questions about stack

Questions about stack?


Installing android

Installing Android

  • Android SDK

  • Eclipse (Helios / Indigo / Juno…)


Android sdk

Android SDK

  • Folder (android-sdk)

    • Tools

    • Platform tools

      • adb

  • SDK Manager

    • Install the platform you are going to use


Add android tools to eclipse

Add Android Tools to Eclipse

  • Help > Install new software >

  • ADT Plugin - http://dl-ssl.google.com/android/eclipse/

  • Windows > Preferences > Android > SDK Location


Hello world

Hello World!

  • New Android Project

  • Select target – which platform are you targeting?


Android programming

JAVA CODE

RESOURCES

MANIFEST


Resources

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

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

Strings.xml

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


Activity main xml

Activity_main.xml

  • Screen layout view


Resources1

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 do we use R to specify resources?


How to run our app

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

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

How to sign

  • Keytool part of JDK…

  • http://developer.android.com/tools/publishing/app-signing.html

  • http://developer.android.com/tools/publishing/preparing.html

  • Right-click on project

    • Android tools

    • Export signed application package


Command line keystore gen

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


Ddms perspective

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

Main Building Blocks


Activities

Activities

  • An activity represents a screen or a window

  • Main activity

  • Other activities


Activity lifecycle

Activity lifecycle

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


When to start stop processes

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 – joining activities (screens)

  • Intents represent events or actions


  • Login