UNIT-I MOBILE APPLICATION
DEVELOPMENT
             Introduction to MAD
• there are different types of Mobile applications;
• Native Applications:
• Native Apps are developed specifically for one platform, and
  can take full advantage of all the device features.
• They are also built using the specific Integrated
  Development Environment (IDE) for the given operating
  systems.
• Android Studio for Android Apps and XCode for iOS Apps.
• IOS apps are written in Objective-C and Swift
• Android apps are written in Java or Kotlin.
• Windows and Blackberry apps are written in C++.
Introduction to MAD
              Introduction to MAD
• Pros
• – They are very fast and responsive because they are built for that
  specific platform.
• – They have the best performance.
• – They are more interactive, intuitive and run much smoother in terms
  of user input and output.
• Cons
• – They are considerably more expensive to develop compared to cross-
  platform and web applications.
• – They require more time to develop as one application has to be
  written in different languages for different platforms.
• – They have a higher cost of maintenance and pushing out updates,
  due to multiple source code bases.
            Introduction to MAD
• Hybrid Applications:
• These are applications developed to be used across multiple
  platforms i.e can be deployed on both iOS and Android
  platforms.
• technologies like HTML, CSS, and JavaScript.
• Some popular frameworks for building Hybrid applications
  include;
• Ionic Framework
• PhoneGap
• Sencha Touch etc.
• Apache Cordova
                       Trends
• Accelerated Mobile Pages (AMP)
  – AMP is a project undertaken by Google in association
    with Twitter and includes several other large search,
    social and web publishing platforms around the world.
  – AMP Project is an open-source website publishing
    technology designed to improve the performance of
    web content and advertisements.
  – As an alternative, the webpage can be displayed
    simultaneously while it is loading instead of making the
    user wait for the whole page to load - it is called lazy
    loading.
                            Trends
• AR & VR Apps
   – With is technology, one could feel like they are inside the
     imaginary world.
• Cloud-driven Mobile Apps
   – A cloud-driven or cloud application is simply an mobile
     application that runs on the server instead of your device.
   – A cloud app will serve same features and characteristics as the
     pure desktop or device app, but functions in the cloud storage.
• Enterprise Apps & Micro-apps
   – In the world of mobile, a micro app is a consumer-oriented
     application delivering highly targeted functionality (e.g. a
     weather forecast app).
                           Trends
• Security In Apps
   – Your phone probably has sensitive information on it, so
     it may be a good idea to install some security software.
      •   Avast Mobile Security
      •   AVG
      •   Sophos Mobile Security
      •   Avira Antivirus
• Swift Is Much Swifter Now
• Artificial Intelligence Is Real Now
• Wearable Devices
                  Trends
• IoT Apps
• Beacons & Location Based Services
VARIOUS PLATFORMS
VARIOUS PLATFORMS
    Introduction to Smart Phones
• Phones used to be all about making calls, but
  now your mobile can do so much more.
• Touchscreen smartphones allows you to
  access the internet, use social media, get live
  news updates, play music and video, and
  much more.
• They almost universally use touchscreens for
  control, however, which can be a challenge for
  people new to the technology.
Introduction to Smart Phones
               Android Platform
• Android is a software package and linux based
  operating system for mobile devices such as tablet
  computers and smartphones.
• Developed by Google
• Java language is mainly used
• The goal of android project is to create a successful
  real-world product that improves the mobile
  experience for end users.
Android Platform
              Android Features
• Messaging
  – SMS and MMS
• Web browser
  – Based on the open-source WebKit layout engine,
    coupled with Chrome's V8 JavaScript engine
    supporting HTML5 and CSS3.
• Multi-touch
  – Android has native support for multi-touch which was
    initially made available in handsets such as the HTC
    Hero.
             Android Features
• Multitasking
  – User can jump from one task to another and same
    time various application can run simultaneously.
• Multiple language support
  – Supports single direction and bi-directional text.
• Connectivity
  – GSM/EDGE, IDEN, CDMA, EV-DO, UMTS,
    Bluetooth, Wi-Fi, LTE, NFC and WiMAX.
                  Android Features
• Media support
    – H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC
      5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
• External storage
    – SQLite, a lightweight relational database, is used for data
      storage purposes.
•   Hardware support
•   Bluetooth
•   Tethering
•   Streaming media support
              Android Features
•   Auto Correction and Dictionary
•   Voice-based features
•   Screen capture
•   TV recording
•   Video calling
•   Accessibility
Android Version and Comparison
Android Version and Comparison
Android Version and Comparison
Android Version and Comparison
Android Version and Comparison
Android Version and Comparison
ANDROID - ARCHITECTURE
            The Linux Kernel
– The foundation of the Android platform is the
  Linux kernel.
– This provides a level of abstraction between the
  device hardware and it contains all the essential
  hardware drivers like camera, keypad, display,
  networking etc.
– Bridge between OS and Hardware
 Hardware Abstraction Layer (HAL)
• The hardware abstraction layer (HAL) provides standard
  interfaces that expose device hardware capabilities to
  the higher-level Java API framework. The HAL consists of
  multiple library modules, each of which implements an
  interface for a specific type of hardware component,
  such as the camera or bluetooth module. When a
  framework API makes a call to access device hardware,
  the Android system loads the library module for that
  hardware component.
• Wat type of action?
                  Libraries
– Libraries including Open-source Web browser
  engine WebKit, well known library libc, SQLite
  database which is a useful repository for storage
  and sharing of application data, libraries to play
  and record audio and video, SSL libraries
  responsible for Internet security etc..
            ANDROID LIBRARIES
• android.app − Provides access to the application model
  and is the cornerstone of all Android applications.
• android.content − Facilitates content access, publishing
  and messaging between applications and application
  components.
• android.database − Used to access data published by
  content providers and includes SQLite database
  management classes.
• android.opengl − A Java interface to the OpenGL ES 3D
  graphics rendering API.
            ANDROID LIBRARIES
• android.os − Provides applications with access to
  standard operating system services including messages,
  system services and inter-process communication.
• android.text − Used to render and manipulate text on a
  device display.
• android.view − The fundamental building blocks of
  application user interfaces.
• android.widget − A rich collection of pre-built user
  interface components such as buttons, labels, list
  views, layout managers, radio buttons etc.
            ANDROID RUNTIME
• Application Framework
  – The Application Framework layer provides many higher-
    level services to applications in the form of Java classes.
  – Activity Manager − Controls all aspects of the
    application lifecycle and activity stack.
  – Content Providers − Allows applications to publish and
    share data with other applications.
  – Resource Manager − Provides access to non-code
    embedded resources such as strings, color settings and
    user interface layouts.
 ANDROID RUNTIME & APPLICATIONS
  – Notifications Manager − Allows applications to
    display alerts and notifications to the user.
  – View System − An extensible set of views used to
    create application user interfaces.
• Applications
  – You will find all the Android application at the top
    layer. You will write your application to be installed
    on this layer only. Examples of such applications are
    Contacts Books, Browser, Games etc.
             ANDROID LIBRARIES
• android.webkit − A set of classes intended to allow
  web-browsing capabilities to be built into applications.
• Android Runtime
   – This section provides a key component called Dalvik Virtual
     Machine which is a kind of Java Virtual Machine specially
     designed and optimized for Android.
   – The Dalvik VM makes use of Linux core features like
     memory management and multi-threading, which is
     intrinsic in the Java language. The Dalvik VM enables every
     Android application to run in its own process.
         Android Runtime (ART)
• Android Runtime (ART) is an application runtime
  environment used by the Android operating system.
• Replacing Dalvik, the process virtual machine
  originally used by Android, ART performs the
  translation of the application’s bytecode into native
  instructions that are later executed by the device’s
  runtime environment.(ART introduced in Android L).
• ART is software layer between applications and
  operating system.
• It provide mechanism for executing java language.
        Android Runtime (ART)
• ART perform two major things to achieve this
  – Runs Android framework and Applications using
    hybrid model of Interpreter, JIT and profile based
    Ahead of time compilation(AOT).
  – Memory Management using Memory allocator
    and Concurrent compacting Garbage collector.
      Android Debug Bridge(ADB)
• Android Debug Bridge (adb) is a versatile command-line
  tool that lets you communicate with a device.
• The adb command facilitates a variety of device actions,
  such as installing and debugging apps, and it provides
  access to a Unix shell that you can use to run a variety of
  commands on a device.
• It is a client-server program that includes three
  components:
   – A client, which sends commands. The client runs on your
     development machine. You can invoke a client from a
     command-line terminal by issuing an adb command.
  Android Debug Bridge(ADB)
– A daemon (adbd), which runs commands on a
  device. The daemon runs as a background process
  on each device.
– A server, which manages communication between
  the client and the daemon. The server runs as a
  background process on your development
  machine.
        Android Studio Features
• Android Studio offers even more features that enhance
  your productivity when building Android apps, such as:
  – A flexible Gradle-based build system
  – A fast and feature-rich emulator
  – A unified environment where you can develop for all
    Android devices
  – Instant Run to push changes to your running app without
    building a new APK
  – Code templates and GitHub integration to help you build
    common app features and import sample code
  – Extensive testing tools and frameworks.
     Android Studio Features
– Lint tools to catch performance, usability, version
  compatibility, and other problems
– C++ and NDK support
– Built-in support for Google Cloud Platform, making
  it easy to integrate Google Cloud Messaging and
  App Engine
   Development environment/IDE
• You can start your Android application development
  on either of the following operating systems −
   – Microsoft Windows XP or later version.
   – Mac OS X 10.5.8 or later version with Intel chip.
   – Linux including GNU C Library 2.7 or later.
• Following is the list of software's you will need
  before you start your Android application
  programming.
   – Java JDK5 or later version
   – Android Studio
  Development environment/IDE
• Starting a new project
• Launching Android Studio and then selecting
  New Project, or you can choose File > New >
  New Project at any time from the IDE itself.
Development environment/IDE
Development environment/IDE
Development environment/IDE
   Development environment/IDE
• 1. Toolbar lets you carry out a wide range of actions, including
  running your app and launching Android tools.
• 2. Navigation bar helps you navigate through your project and
  open files for editing. It provides a more compact view of the
  structure visible in the Project window.
• 3. Editor window is where you create and modify code.
  Depending on the current file type, the editor can change. For
  example, when viewing a layout file, the editor displays the
  Layout Editor.
• 4. Tool window bar runs around the outside of the IDE window
  and contains the buttons that allow you to expand or collapse
  individual tool windows.
  Development environment/IDE
• 5. Tool windows give you access to specific
  tasks like project management, search, version
  control, and more. You can expand them and
  collapse them.
• 6. Status bar displays the status of your
  project and the IDE itself, as well as any
  warnings or messages.
               Gradle Build System
• Android Studio uses Gradle as the foundation of the build
  system, with more Android-specific capabilities provided by
  the Android plugin for Gradle.
• This build system runs as an integrated tool from the
  Android Studio menu, and independently from the
  command line.
• You can use the features of the build system to do the
  following:
   – Customize, configure, and extend the build process.
   – Create multiple APKs for your app, with different features using
     the same project and modules.
   – Reuse code and resources across sourcesets.
                  Emulator Setup
• The emulator lets you prototype, develop and test
  Android applications without using a physical device.
• Creating AVD
   – If you want to emulate a real device, first crate an AVD
     with the same device configurations as real device, then
     launch this AVD from AVD manager.
• Changing Orientation
   – Usually by default when you launch the emulator, its
     orientation is vertical, but you can change it orientation
     by pressing Ctrl+F11 key from keyboard.
             Emulator Commands
•   Home - Shifts to main screen
•   F2 - Toggles context sensitive menu
•   F3 - Bring out call log
•   F4 - End call
•   F5 - Search
•   F6 - Toggle trackball mode
•   F7 - Power button
•   F8 - Toggle data network
•   Ctrl+F5 - Ring Volume up
•   Ctrl+F6 - Ring Volume down
Android - UI Layouts
Android - UI Layouts
           Android Layout Types
• Linear Layout is a view group that aligns all children
  in a single direction, vertically or horizontally.
• Relative Layout is a view group that displays child
  views in relative positions.
• Table Layout is a view that groups views into rows
  and columns.
• Absolute Layout enables you to specify the exact
  location of its children.
• Frame Layout is a placeholder on screen that you
  can use to display a single view.
          Android Layout Types
• List View is a view group that displays a list of
  scrollable items.
• Grid View is a View Group that displays items
  in a two-dimensional, scrollable grid.
                Layout Attributes
• android:id - This is the ID which uniquely identifies the view.
• android:layout_width - This is the width of the layout.
• android:layout_height - This is the height of the layout
• android:layout_marginTop - This is the extra space on the
  top side of the layout.
• android:layout_marginBottom - This is the extra space on
  the bottom side of the layout.
• android:layout_marginLeft - This is the extra space on the
  left side of the layout.
• android:layout_marginRight - This is the extra space on the
  right side of the layout.
               Layout Attributes
• android:layout_gravity - This specifies how child Views
  are positioned.
• android:layout_weight - This specifies how much of the
  extra space in the layout should be allocated to the View.
• android:layout_x - This specifies the x-coordinate of the
  layout.
• android:layout_y - This specifies the y-coordinate of the
  layout.
• android:layout_width - This is the width of the layout.
• android:layout_width - This is the width of the layout.
            Layout Attributes
• android:paddingLeft - This is the left padding
  filled for the layout.
• android:paddingRight - This is the right
  padding filled for the layout.
• android:paddingTop - This is the top padding
  filled for the layout.
• android:paddingBottom - This is the bottom
  padding filled for the layout.
           Generated R.Javafile
• R.java is neat. R.java is elegant. Due to its
  subversiveness (in a good way) its makings are
  implicit. It is fun to learn about Android.R.
• At a mile high level, every application has resouces.
  Familiar example of resources are strings, colors,
  and bitmaps. Instead of hard coding strings in an
  application one will use an id for a string.
• Let's start with strings and see how they are used.
Generated R.Javafile
            XML representation
• XML stands for Extensible Mark-up Language.
• XML is a very popular format and commonly used for
  sharing data on the internet.
• This chapter explains how to parse the XML file and
  extract necessary information from it.
• Android provides three types of XML parsers which
  are DOM,SAX and XMLPullParser.
• Among all of them android recommend XMLPullParser
  because it is efficient and easy to use.
• So we are going to use XMLPullParser for parsing XML.
            XML representation
• The first step is to identify the fields in the
  XML data in which you are interested in.
• For example. In the XML given below we
  interested in getting temperature only.
                 XML Elements
• Prolog - An XML file starts with a prolog. The first line
  that contains the information about a file is prolog
• Events - An XML file has many events. Event could be
  like this. Document starts , Document ends, Tag start ,
  Tag end and Text e.t.
• Text - Apart from tags and events, and xml file also
  contains simple text. Such as GB is a text in the
  country tag.
• Attributes - Attributes are the additional properties of
  a tag such as value e.t.c