SlideShare une entreprise Scribd logo
1  sur  45
Java Essentials for Android

Presented by

Adrian Mikeliunas

Adrian@Mikeliunas.com

TASKMobileSolutions.com
Java Essentials for Android




MoDevAcademy

MoDevAcademy will offer professional training across
platforms that include beginner, intermediate and
advanced courses.

The format will be one day courses that can be taken
individually or paired for a multi-day experience. The
Academy intended to fill a much needed void in the
market for in-depth mobile developer training.




                                                         2
Upcoming Classes

Schedule:

 • January 22nd: Starting up with iOS Development

 • January 23rd: Expert Objective-C

 • January 24th: Advanced Xcode Development


Register at MoDevAcademy.com/Registration
Online Resources

The references in this presentation, and many other
resources are available at:

http://Gomodev.com/MoDevAcademyResources
Java Essentials for Android




Agenda

 Java Similarities

 Java Differences

 Android Programming with Java in Eclipse

 Resources
      Google Samples
      F-droid.org
      SourceFourge.net




                                             5
Java Essentials for Android




Android & Java Comparisons
Similarities

Differences




                              6
Java Essentials for Android




Android <> Java

 Android is Google’s Operating System, combining Linux
  with their own version of Java, named Dalvik

 Dalvik uses a subset of Harmony, an Apache Software
  Foundation project

 Dalvik is open-source software. Is the name of a fishing
  village in Iceland

                   http://en.wikipedia.org/wiki/Dalvik_virtual_machine




                                                                         7
Java Essentials for Android




Android/Java Similarities
                                     java.io - File and stream I/O
                                     java.lang - Language & exception
 Android uses Java syntax           support
                                     java.math - Big numbers, rounding,
                                     precision
 Android uses similar APIs          java.net - Network I/O, URLs, sockets
                                     java.nio - File and channel I/O
                                     java.security - Authorization, certificates,
 Android, supports a relatively     public keys
                                     java.sql - Database interfaces
  large subset of the Java           java.text - Formatting, natural language,
                                     collation
  Standard Edition 5.0 library       …


 Java files on Android are
  compiled into .class files and
  then in dalvik executables(.dex)


                                                                                    8
Java Essentials for Android




Android/Java Differences

 Unlike Java VMs, which are stack machines, the Dalvik
  VM uses a register-based architecture

 Dalvik does not align to Java SE nor Java ME class library
  profiles

 Java is a programming language, while Android is a
  mobile phone platform




                                                               9
Java Essentials for Android




Android/Java Differences

 Android does not use the Abstract Window Toolkit nor the
  Swing library. User Interface is built using View objects

 Android layout behavior is encoded in the containers
  using XML files, unlike Java where Layout managers can
  be applied to any container widget

 Android relies on a master AndroidManifest.xml file
      There is no Main class
      You need to define default activity here
      THIS IS A MANUAL METHOD


                                                              10
Java Essentials for Android




Android & Eclipse
Setup

Components

Development




                              11
Java Essentials for Android




Android Development Setup - 1

    Your Development Computer
           Install Java Development Kit (JDK)
                 www.oracle.com/technetwork/Java/javase/
                  downloads/index.html
           Install Eclipse Classic version
                 www.eclipse.org/downloads

    Requirements:
           Windows, Mac, or Linux
          developer.android.com/sdk/requirements.html



                                                            12
JDK




www.oracle.com/technetwork/Java/javase/
downloads/index.html

                                          13
Eclipse




      www.eclipse.org/downloads


                                  14
Android Development Setup - 2
 Downloading the SDK Starter Package
    Install Android SDK
     http://developer.android.com/sdk/index.html




                                                   15
Android SDK Manager




                      16
Java Essentials for Android




Android Development Setup – 3a

 ADT Plugin for Eclipse
      Start Eclipse
      Select Help > Install New Software....
      Click Add, in the top-right corner
        In the Add Repository dialog that appears,
        enter "ADT Plugin" for the Name
        Location: https://dl-
           ssl.google.com/android/eclipse/
            Click OK.


                                                      17
Java Essentials for Android




Android Development Setup – 3b

    ADT Plugin for Eclipse
      In the Available Software dialog, select the
       checkbox next to Developer Tools and click Next.
      In the next window, you'll see a list of the tools to be
       downloaded. Click Next.
      Read and accept the license agreements, then
       click Finish.

    When the installation completes,
           Restart Eclipse!



                                                                  18
Java Essentials for Android




      Android Development Setup – 3c
          Select Window > Preferences...

          Select Android from the left panel
                 You may see a dialog asking whether you want to send
                  usage statistics to Google. If so, make your choice and
                  click Proceed. You cannot continue with this procedure
                  until you click Proceed.

          For the SDK Location in the main panel, click Browse... &
           locate your downloaded SDK directory

          Click Apply, then OK
http://developer.android.com/sdk/eclipse-adt.html#installing


                                                                            19
Java Essentials for Android




  Android Development Tools (ADT)
The Android SDK includes several tools &
 utilities to help you create, test, & debug
 your projects
ADT plug-in conveniently incorporates
 most of these tools into the Eclipse IDE,
 where you can access them from the
 DDMS perspective



                                               20
Java Essentials for Android




ADT Inventory

 The Android Emulator
 Dalvik Debug Monitoring Service
  (DDMS)
 Android Asset Packaging Tool (AAPT)
 Android Debug Bridge (ADB)


                                        21
Java Essentials for Android




ADT Inventory-2
  The following additional tools are also
available:
 SQLite3 A database tool
 Traceview Graphical analysis tool
 MkSDCard
 dx: java bytecode to Dalvik executable
 activityCreator Script

                                            22
Java Essentials for Android




Android SDK

          android.jar
          Documentation
          Samples directory
          Tools directory
          usb_driver
                               23
• Eclipse Navigation

                       • Package
                         Explorer
                       • Code Editor
                       • Outline View




                                        •   2
                                            4
• Eclipse Tools-DDMS

                       Dalvik
                       Debug
                       Monitor
                       Service




                                 •   2
                                     5
Java Essentials for Android




   Android Emulator

 Create an Android Virtual Device

 Run it!




                                     26
Java Essentials for Android




 Android Architecture
 Applications

 Application
  framework

 Libraries

 Android Runtime
  (Dalvik VM)

 Linux 2.6 Kernel




                               27
28
Java Essentials for Android




   Android Layers
 Linux kernel provides drivers for the Android hardware,
  networking, file system access & inter-process-communication

 Libraries are mostly written in C or C++

 Core Libraries are the core development kit including utility,
  i.o. etc

 Dalvik Virtual Machine is an optimized Java VM

 Application Framework is the API to developers

 Applications are user facing programs


                                                                   29
Java Essentials for Android




Android Applications

• Each application runs in its own
  process, gets unique identifier &
  runs its own instance of Dalvik VM

             This way the processes are isolated & crash of one
              application does not bring down the whole system!




                                                                   30
Android Programming
 System Level – modifying the Android system
  code & adapting it to various hardware platforms.
  It also involves creating additional services &
  features in the android system itself. C. C++


 Application level – creating software products &
  services which sits on top of the Android software
  stack & interacts with the hardware through the
  underlying Android platform. Java.


                                                       31
Java Essentials for Android




 Application Development Basics

 Activity
    Presents visual interface to the user
    Each activity has a separate window
    to draw the visual component but if required it can use
     more than one window also

 Services
    runs in the background and carries out some
     background process while the other visual component s
     are running in the foreground


                                                               32
Java Essentials for Android




      Application Development Basics-2

 Broadcast receivers
   responsible for receiving and reacting to broadcasted
    messages

 Content providers
   This provides specific set of data from one application to
    other applications. Used in conjunction with Content resolver
    which provide methods for inter process communication

 Widgets
   These are programs anchored to the home screen
    providing information updated fairly frequently


                                                                    33
Android Activities
Each Android application must designate a default activity within
the Android manifest file
35
Android Activity Class
The Activity base class defines a series of events that governs the life cycle of an
   activity:

onCreate() — Called when the activity is first created

onStart() — Called when the activity becomes visible to the user

onResume() —when the activity starts interacting with the user

onPause() —current activity is being paused & the previous activity is being resumed

onStop() —when the activity is no longer visible to the user

onDestroy() — Called before the activity is destroyed by the system
   (either manually or by the system to conserve memory)

onRestart() —when the activity has been stopped & is restarting



                                                                                       36
Android Activity Class (2)

public void onStart()
  {
  super.onStart();
  Log.d(tag, ―In the onStart() event‖);
  }
public void onRestart()
  {
  super.onRestart();
  Log.d(tag, ―In the onRestart() event‖);
  }


                                            37
Android Activities
 To create an activity, you create a Java class
  that extends the Activity base class:
  package com.example.Activities;
  import android.app.Activity;
  import android.os.Bundle;
  public class MainActivity extends Activity {

      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      }
  }


                                                          38
Android Activities-2

 Your activity class would then load its UI component
  using the XML file defined in your res/layout folder. In this
  example, you would load the UI from the main.xml file:
   setContentView(R.layout.main);

 Every activity you have in your application must be
  declared in your AndroidManifest.xml file




                                                                  39
Android Activities (3)
<?xml version=‖1.0‖ encoding=‖utf-8‖?>
<manifest xmlns:android=‖http://schemas.android.com/apk/res/android‖
  package=‖com.example.Activities‖
  android:versionCode=‖1‖
  android:versionName=‖1.0‖>
  <application android:icon=‖@drawable/icon‖
           android:label=‖@string/app_name‖>
           <activity android:name=”.MainActivity”
                      android:label=‖@string/app_name‖>
                      <intent-filter>
                      <action android:name=‖android.intent.action.MAIN‖ />
                      <category
                      android:name=‖android.intent.category.LAUNCHER‖ />
                      </intent-filter>
           </activity>
  </application>
  <uses-sdk android:minSdkVersion=‖9‖ />
</manifest>



                                                                             40
Android Layouts

 An Android layout is a class that handles arranging
  the way its children appear on the screen
   Anything that is a View (or inherits from View) can be a
    child of a layout

 All of the layouts inherit from ViewGroup (which
  inherits from View) so you can nest layouts
   You could also create your own custom layout by making a
    class that inherits from ViewGroup



                                                               41
The Android Layouts are:


   AbsoluteLayout
   FrameLayout
   LinearLayout
   RelativeLayout
   TableLayout
                           42
Java Essentials for Android




Android Resources

 Google Samples

 F-droid.org

 sourceforge.net




                              43
Java Essentials for Android




   Example: Timesheet




 Timesheet is an application designed primarily for contractors
  and freelancers to track the time spent on different tasks.
  http://tastycactus.com/projects/timesheet/
f-droid.org/repository/browse/?fdfilter=timesheet&fdid=com.tastycactus.timesheet
play.google.com/store/apps/details?id=com.tastycactus.timesheet




                                                                                   44
Java Essentials for Android




Java Essentials for Android


                              Q& A



                                     45

Contenu connexe

Tendances

Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorialnazzf
 
Basics of Android
Basics of Android Basics of Android
Basics of Android sabi_123
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Opersys inc.
 
Android and its feature
Android and its featureAndroid and its feature
Android and its featureShubham Kumar
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Trainingchandutata
 
Android development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWangAndroid development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWang佐軒 王
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...IJCNCJournal
 
Android application development
Android application developmentAndroid application development
Android application developmentSteve Smith
 
Android summer training report
Android summer training reportAndroid summer training report
Android summer training reportShashendra Singh
 
Android Overview
Android OverviewAndroid Overview
Android OverviewRaju Kadam
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio OverviewSalim Hosen
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principlesHenk Laracker
 
Android development basics
Android development basicsAndroid development basics
Android development basicsPramesh Gautam
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfweerabahu
 
2018 top ide's for andriod development
2018 top ide's for andriod development2018 top ide's for andriod development
2018 top ide's for andriod developmentQamar Abbas
 
Android application development
Android application developmentAndroid application development
Android application developmentMadhuprakashR1
 

Tendances (20)

Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorial
 
Basics of Android
Basics of Android Basics of Android
Basics of Android
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012
 
Android and its feature
Android and its featureAndroid and its feature
Android and its feature
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Training
 
Android development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWangAndroid development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWang
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android summer training report
Android summer training reportAndroid summer training report
Android summer training report
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Android Basic
Android BasicAndroid Basic
Android Basic
 
Android
Android Android
Android
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio Overview
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 
ANDROID
ANDROIDANDROID
ANDROID
 
Android development basics
Android development basicsAndroid development basics
Android development basics
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdf
 
2018 top ide's for andriod development
2018 top ide's for andriod development2018 top ide's for andriod development
2018 top ide's for andriod development
 
Android application development
Android application developmentAndroid application development
Android application development
 

Similaire à Java Essentials for Android Development

Similaire à Java Essentials for Android Development (20)

Android_Studio_Structure.docx
Android_Studio_Structure.docxAndroid_Studio_Structure.docx
Android_Studio_Structure.docx
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android My Seminar
Android My SeminarAndroid My Seminar
Android My Seminar
 
Notes Unit2.pptx
Notes Unit2.pptxNotes Unit2.pptx
Notes Unit2.pptx
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorial
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guide
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 
androidPramming.ppt
androidPramming.pptandroidPramming.ppt
androidPramming.ppt
 
Session 2 beccse
Session 2 beccseSession 2 beccse
Session 2 beccse
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 
Ganar el desafio android
Ganar el desafio androidGanar el desafio android
Ganar el desafio android
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android application developement
Android application developementAndroid application developement
Android application developement
 
Android
Android Android
Android
 
Android OS
Android OSAndroid OS
Android OS
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 
Introduction To Android For Beginners.
Introduction To Android For Beginners.Introduction To Android For Beginners.
Introduction To Android For Beginners.
 
Android development process- thorsignia
Android development process- thorsigniaAndroid development process- thorsignia
Android development process- thorsignia
 
Android development classes in chandigarh : Big Boxx Academy
Android development classes in chandigarh : Big Boxx AcademyAndroid development classes in chandigarh : Big Boxx Academy
Android development classes in chandigarh : Big Boxx Academy
 
Android - Getting started with Android
Android - Getting started with Android Android - Getting started with Android
Android - Getting started with Android
 

Plus de Adrian Mikeliunas

Office Hour Week 14 Adrian.pptx
Office Hour Week 14 Adrian.pptxOffice Hour Week 14 Adrian.pptx
Office Hour Week 14 Adrian.pptxAdrian Mikeliunas
 
CISSP introduction 2016 Udemy Course
CISSP introduction 2016 Udemy CourseCISSP introduction 2016 Udemy Course
CISSP introduction 2016 Udemy CourseAdrian Mikeliunas
 
Introduction to WordPress Class 6
Introduction to WordPress Class 6Introduction to WordPress Class 6
Introduction to WordPress Class 6Adrian Mikeliunas
 
Introduction to WordPress Class 5
Introduction to WordPress Class 5Introduction to WordPress Class 5
Introduction to WordPress Class 5Adrian Mikeliunas
 
Introduction to WordPress Class 4
Introduction to WordPress Class 4Introduction to WordPress Class 4
Introduction to WordPress Class 4Adrian Mikeliunas
 
Introduction to WordPress Class 3
Introduction to WordPress Class 3Introduction to WordPress Class 3
Introduction to WordPress Class 3Adrian Mikeliunas
 
Introduction to WordPress Class 2
Introduction to WordPress Class 2Introduction to WordPress Class 2
Introduction to WordPress Class 2Adrian Mikeliunas
 
Genymotion Android fast development
Genymotion Android fast development Genymotion Android fast development
Genymotion Android fast development Adrian Mikeliunas
 
Cómo usar la tecnología para generar más Seguridad y desarrollo local
Cómo usar la tecnología para generar más Seguridad y desarrollo localCómo usar la tecnología para generar más Seguridad y desarrollo local
Cómo usar la tecnología para generar más Seguridad y desarrollo localAdrian Mikeliunas
 
Introduction to WordPress Class 1
Introduction to WordPress Class 1Introduction to WordPress Class 1
Introduction to WordPress Class 1Adrian Mikeliunas
 
Cyber Security At The Cinema
Cyber Security At The CinemaCyber Security At The Cinema
Cyber Security At The CinemaAdrian Mikeliunas
 

Plus de Adrian Mikeliunas (16)

Office Hour Week 14 Adrian.pptx
Office Hour Week 14 Adrian.pptxOffice Hour Week 14 Adrian.pptx
Office Hour Week 14 Adrian.pptx
 
WordPress Security 2018
WordPress Security 2018WordPress Security 2018
WordPress Security 2018
 
CISSP introduction 2016 Udemy Course
CISSP introduction 2016 Udemy CourseCISSP introduction 2016 Udemy Course
CISSP introduction 2016 Udemy Course
 
Introduction to WordPress Class 6
Introduction to WordPress Class 6Introduction to WordPress Class 6
Introduction to WordPress Class 6
 
Introduction to WordPress Class 5
Introduction to WordPress Class 5Introduction to WordPress Class 5
Introduction to WordPress Class 5
 
Introduction to WordPress Class 4
Introduction to WordPress Class 4Introduction to WordPress Class 4
Introduction to WordPress Class 4
 
Introduction to WordPress Class 3
Introduction to WordPress Class 3Introduction to WordPress Class 3
Introduction to WordPress Class 3
 
Introduction to WordPress Class 2
Introduction to WordPress Class 2Introduction to WordPress Class 2
Introduction to WordPress Class 2
 
Genymotion Android fast development
Genymotion Android fast development Genymotion Android fast development
Genymotion Android fast development
 
Cómo usar la tecnología para generar más Seguridad y desarrollo local
Cómo usar la tecnología para generar más Seguridad y desarrollo localCómo usar la tecnología para generar más Seguridad y desarrollo local
Cómo usar la tecnología para generar más Seguridad y desarrollo local
 
Linux introduction Class 03
Linux introduction Class 03Linux introduction Class 03
Linux introduction Class 03
 
Linux introduction Class 02
Linux introduction Class 02Linux introduction Class 02
Linux introduction Class 02
 
Linux introduction, class 1
Linux introduction, class 1Linux introduction, class 1
Linux introduction, class 1
 
Introduction to WordPress Class 1
Introduction to WordPress Class 1Introduction to WordPress Class 1
Introduction to WordPress Class 1
 
Task deck
Task deckTask deck
Task deck
 
Cyber Security At The Cinema
Cyber Security At The CinemaCyber Security At The Cinema
Cyber Security At The Cinema
 

Dernier

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Java Essentials for Android Development

  • 1. Java Essentials for Android Presented by Adrian Mikeliunas Adrian@Mikeliunas.com TASKMobileSolutions.com
  • 2. Java Essentials for Android MoDevAcademy MoDevAcademy will offer professional training across platforms that include beginner, intermediate and advanced courses. The format will be one day courses that can be taken individually or paired for a multi-day experience. The Academy intended to fill a much needed void in the market for in-depth mobile developer training. 2
  • 3. Upcoming Classes Schedule: • January 22nd: Starting up with iOS Development • January 23rd: Expert Objective-C • January 24th: Advanced Xcode Development Register at MoDevAcademy.com/Registration
  • 4. Online Resources The references in this presentation, and many other resources are available at: http://Gomodev.com/MoDevAcademyResources
  • 5. Java Essentials for Android Agenda  Java Similarities  Java Differences  Android Programming with Java in Eclipse  Resources  Google Samples  F-droid.org  SourceFourge.net 5
  • 6. Java Essentials for Android Android & Java Comparisons Similarities Differences 6
  • 7. Java Essentials for Android Android <> Java  Android is Google’s Operating System, combining Linux with their own version of Java, named Dalvik  Dalvik uses a subset of Harmony, an Apache Software Foundation project  Dalvik is open-source software. Is the name of a fishing village in Iceland http://en.wikipedia.org/wiki/Dalvik_virtual_machine 7
  • 8. Java Essentials for Android Android/Java Similarities java.io - File and stream I/O java.lang - Language & exception  Android uses Java syntax support java.math - Big numbers, rounding, precision  Android uses similar APIs java.net - Network I/O, URLs, sockets java.nio - File and channel I/O java.security - Authorization, certificates,  Android, supports a relatively public keys java.sql - Database interfaces large subset of the Java java.text - Formatting, natural language, collation Standard Edition 5.0 library …  Java files on Android are compiled into .class files and then in dalvik executables(.dex) 8
  • 9. Java Essentials for Android Android/Java Differences  Unlike Java VMs, which are stack machines, the Dalvik VM uses a register-based architecture  Dalvik does not align to Java SE nor Java ME class library profiles  Java is a programming language, while Android is a mobile phone platform 9
  • 10. Java Essentials for Android Android/Java Differences  Android does not use the Abstract Window Toolkit nor the Swing library. User Interface is built using View objects  Android layout behavior is encoded in the containers using XML files, unlike Java where Layout managers can be applied to any container widget  Android relies on a master AndroidManifest.xml file  There is no Main class  You need to define default activity here  THIS IS A MANUAL METHOD 10
  • 11. Java Essentials for Android Android & Eclipse Setup Components Development 11
  • 12. Java Essentials for Android Android Development Setup - 1  Your Development Computer  Install Java Development Kit (JDK)  www.oracle.com/technetwork/Java/javase/ downloads/index.html  Install Eclipse Classic version  www.eclipse.org/downloads  Requirements:  Windows, Mac, or Linux developer.android.com/sdk/requirements.html 12
  • 14. Eclipse www.eclipse.org/downloads 14
  • 15. Android Development Setup - 2  Downloading the SDK Starter Package  Install Android SDK http://developer.android.com/sdk/index.html 15
  • 17. Java Essentials for Android Android Development Setup – 3a  ADT Plugin for Eclipse  Start Eclipse  Select Help > Install New Software....  Click Add, in the top-right corner  In the Add Repository dialog that appears,  enter "ADT Plugin" for the Name  Location: https://dl- ssl.google.com/android/eclipse/  Click OK. 17
  • 18. Java Essentials for Android Android Development Setup – 3b  ADT Plugin for Eclipse  In the Available Software dialog, select the checkbox next to Developer Tools and click Next.  In the next window, you'll see a list of the tools to be downloaded. Click Next.  Read and accept the license agreements, then click Finish.  When the installation completes,  Restart Eclipse! 18
  • 19. Java Essentials for Android Android Development Setup – 3c  Select Window > Preferences...  Select Android from the left panel  You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed.  For the SDK Location in the main panel, click Browse... & locate your downloaded SDK directory  Click Apply, then OK http://developer.android.com/sdk/eclipse-adt.html#installing 19
  • 20. Java Essentials for Android Android Development Tools (ADT) The Android SDK includes several tools & utilities to help you create, test, & debug your projects ADT plug-in conveniently incorporates most of these tools into the Eclipse IDE, where you can access them from the DDMS perspective 20
  • 21. Java Essentials for Android ADT Inventory  The Android Emulator  Dalvik Debug Monitoring Service (DDMS)  Android Asset Packaging Tool (AAPT)  Android Debug Bridge (ADB) 21
  • 22. Java Essentials for Android ADT Inventory-2 The following additional tools are also available:  SQLite3 A database tool  Traceview Graphical analysis tool  MkSDCard  dx: java bytecode to Dalvik executable  activityCreator Script 22
  • 23. Java Essentials for Android Android SDK  android.jar  Documentation  Samples directory  Tools directory  usb_driver 23
  • 24. • Eclipse Navigation • Package Explorer • Code Editor • Outline View • 2 4
  • 25. • Eclipse Tools-DDMS Dalvik Debug Monitor Service • 2 5
  • 26. Java Essentials for Android Android Emulator  Create an Android Virtual Device  Run it! 26
  • 27. Java Essentials for Android Android Architecture  Applications  Application framework  Libraries  Android Runtime (Dalvik VM)  Linux 2.6 Kernel 27
  • 28. 28
  • 29. Java Essentials for Android Android Layers  Linux kernel provides drivers for the Android hardware, networking, file system access & inter-process-communication  Libraries are mostly written in C or C++  Core Libraries are the core development kit including utility, i.o. etc  Dalvik Virtual Machine is an optimized Java VM  Application Framework is the API to developers  Applications are user facing programs 29
  • 30. Java Essentials for Android Android Applications • Each application runs in its own process, gets unique identifier & runs its own instance of Dalvik VM  This way the processes are isolated & crash of one application does not bring down the whole system! 30
  • 31. Android Programming  System Level – modifying the Android system code & adapting it to various hardware platforms. It also involves creating additional services & features in the android system itself. C. C++  Application level – creating software products & services which sits on top of the Android software stack & interacts with the hardware through the underlying Android platform. Java. 31
  • 32. Java Essentials for Android Application Development Basics  Activity  Presents visual interface to the user  Each activity has a separate window  to draw the visual component but if required it can use more than one window also  Services  runs in the background and carries out some background process while the other visual component s are running in the foreground 32
  • 33. Java Essentials for Android Application Development Basics-2  Broadcast receivers  responsible for receiving and reacting to broadcasted messages  Content providers  This provides specific set of data from one application to other applications. Used in conjunction with Content resolver which provide methods for inter process communication  Widgets  These are programs anchored to the home screen providing information updated fairly frequently 33
  • 34. Android Activities Each Android application must designate a default activity within the Android manifest file
  • 35. 35
  • 36. Android Activity Class The Activity base class defines a series of events that governs the life cycle of an activity: onCreate() — Called when the activity is first created onStart() — Called when the activity becomes visible to the user onResume() —when the activity starts interacting with the user onPause() —current activity is being paused & the previous activity is being resumed onStop() —when the activity is no longer visible to the user onDestroy() — Called before the activity is destroyed by the system (either manually or by the system to conserve memory) onRestart() —when the activity has been stopped & is restarting 36
  • 37. Android Activity Class (2) public void onStart() { super.onStart(); Log.d(tag, ―In the onStart() event‖); } public void onRestart() { super.onRestart(); Log.d(tag, ―In the onRestart() event‖); } 37
  • 38. Android Activities  To create an activity, you create a Java class that extends the Activity base class: package com.example.Activities; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } 38
  • 39. Android Activities-2  Your activity class would then load its UI component using the XML file defined in your res/layout folder. In this example, you would load the UI from the main.xml file: setContentView(R.layout.main);  Every activity you have in your application must be declared in your AndroidManifest.xml file 39
  • 40. Android Activities (3) <?xml version=‖1.0‖ encoding=‖utf-8‖?> <manifest xmlns:android=‖http://schemas.android.com/apk/res/android‖ package=‖com.example.Activities‖ android:versionCode=‖1‖ android:versionName=‖1.0‖> <application android:icon=‖@drawable/icon‖ android:label=‖@string/app_name‖> <activity android:name=”.MainActivity” android:label=‖@string/app_name‖> <intent-filter> <action android:name=‖android.intent.action.MAIN‖ /> <category android:name=‖android.intent.category.LAUNCHER‖ /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion=‖9‖ /> </manifest> 40
  • 41. Android Layouts  An Android layout is a class that handles arranging the way its children appear on the screen  Anything that is a View (or inherits from View) can be a child of a layout  All of the layouts inherit from ViewGroup (which inherits from View) so you can nest layouts  You could also create your own custom layout by making a class that inherits from ViewGroup 41
  • 42. The Android Layouts are: AbsoluteLayout FrameLayout LinearLayout RelativeLayout TableLayout 42
  • 43. Java Essentials for Android Android Resources  Google Samples  F-droid.org  sourceforge.net 43
  • 44. Java Essentials for Android Example: Timesheet  Timesheet is an application designed primarily for contractors and freelancers to track the time spent on different tasks. http://tastycactus.com/projects/timesheet/ f-droid.org/repository/browse/?fdfilter=timesheet&fdid=com.tastycactus.timesheet play.google.com/store/apps/details?id=com.tastycactus.timesheet 44
  • 45. Java Essentials for Android Java Essentials for Android Q& A 45

Notes de l'éditeur

  1. This session focuses on Java concepts that you will need in order to develop Android apps. It will serve as an overview of the fundamentals of the Java programming language, and compare and contrast it with other C-like languages like C, C++, C#, and Objective C. Also covered are the best sources for templates and libraries to speed up your learning curve!
  2. http://en.wikipedia.org/wiki/Comparison_of_Java_and_Android_APIhttp://en.wikipedia.org/wiki/Dalvik_virtual_machinehttp://en.wikipedia.org/wiki/Oracle_v._GoogleIn May 2012 the jury in this case found that Google did not infringe on Oracle&apos;s patents, and the trial judge ruled that the structure of the Java APIs used by Google was not copyrightable.…On the primary copyright issue of the APIs, the court ruled that &quot;So long as the specific code used to implement a method is different, anyone is free under the Copyright Act to write his or her own code to carry out exactly the same function or specification of any methods used in the Java API. It does not matter that the declaration or method header lines are identical.
  3. http://www.zdnet.com/blog/burnette/java-vs-android-apis/504Supported java.io - File and stream I/Ojava.lang (except java.lang.management) - Language and exceptionsupportjava.math - Big numbers, rounding, precisionjava.net - Network I/O, URLs, socketsjava.nio - File and channel I/Ojava.security - Authorization, certificates, public keysjava.sql - Database interfacesjava.text - Formatting, natural language, collationjava.util (including java.util.concurrent) - Lists, maps, sets, arrays, collectionsjavax.crypto - Ciphers, public keysjavax.net - Socket factories, SSLjavax.security (except javax.security.auth.kerberos, javax.security.auth.spi, and javax.security.sasl)javax.sound - Music and sound effectsjavax.sql (except javax.sql.rowset) - More database interfacesjavax.xml.parsers - XML parsingorg.w3c.dom (but not sub-packages) - DOM nodes and elementsorg.xml.sax - Simple API for XMLNot supported These packages, normally a part of the Java 2 Platform Standard Edition, are not supported by Android.java.appletjava.awtjava.beansjava.lang.management
  4. http://en.wikipedia.org/wiki/Dalvik_virtual_machinehttp://www.differencebetween.com/difference-between-android-and-vs-java/http://gamedev.stackexchange.com/questions/4288/how-different-is-java-for-jre-vs-java-for-androidFor C/C++ geeks, you can use NDK (Native Development Kit) but you need some Java bootstrap code and JNI knowledge
  5. http://developer.android.com/sdk/installing.htmlhttp://www.eclipse.org/downloads/
  6. http://developer.android.com/sdk/installing.htmlhttp://www.eclipse.org/downloads/
  7. http://developer.android.com/sdk/installing.htmlhttp://www.eclipse.org/downloads/
  8. http://developer.android.com/sdk/installing.htmlhttp://www.eclipse.org/downloads/
  9. http://developer.android.com/sdk/installing.htmlhttp://www.eclipse.org/downloads/
  10. http://en.wikipedia.org/wiki/Dalvik_(software)http://www.herongyang.com/Android/Project-dx-Command-Converting-class-Files-into-dex-File.html
  11. Developer.android.com/tools/debugging/ddms.htmlhttp://www.brighthub.com/mobile/google-android/articles/25023.aspx
  12. Source http://developer.android.com/images/system-architecture.jpg
  13. Beg. Android dev 2011Pg 28
  14. http://www.learn-android.com/2010/01/05/android-layout-tutorial/6/http://www.learn-android.com/2010/01/05/android-layout-tutorial/3/
  15. http://sourceforge.net/directory/os%3Awindows/freshness%3Arecently-updated/?q=android&amp;sort=popular
  16. http://f-droid.org/repository/browse/?fdfilter=timesheet&amp;fdid=com.tastycactus.timesheet