Android App Development - Ahmad Tayeb

Page created by Tiffany Weaver
 
CONTINUE READING
Android App Development - Ahmad Tayeb
Android App
Development
Ahmad Tayeb
Android App Development - Ahmad Tayeb
Ahmad Tayeb

   Lecturer @ Department of Information Technology, Faculty of Computing and
    Information Technology, KAU
   Master degree from Information Sciences and Technologies , B. Thomas
    Golisano College of Computing and Information Sciences, Rochester Institute
    of Technology , Rochester, NY, USA
   http://ahmadt.com
   Twitter: @ahmad_tayeb
Android App Development - Ahmad Tayeb
Android

   Android is a software package and Linux based operating system for mobile
    devices such as tablet computers and smartphones.
   It is developed by Google and later the OHA (Open Handset Alliance). Java
    language is mainly used to write the android code even though other
    languages can be used.
   What is Open Handset Alliance (OHA) ?
    It's a consortium of 84 companies such as google, samsung, AKM, synaptics,
    KDDI, Garmin, Teleca, Ebay, Intel etc.
Android App Development - Ahmad Tayeb
Features of Android

   It is open-source.
   Anyone can customize the
    Android Platform.
   There are a lot of mobile
    applications that can be chosen
    by the consumer.
Android App Development - Ahmad Tayeb
Android Architecture

   Linux kernel
   Native libraries (middleware)
   Android Runtime
   Application Framework
   Applications
Android App Development - Ahmad Tayeb
Android Architecture
1) Linux kernel
   It is the heart of android architecture that exists at the root of android
    architecture.
   Linux kernel is responsible for device drivers, power management, memory
    management, device management and resource access.
Android App Development - Ahmad Tayeb
Android Architecture
2) Native Libraries
   On the top of Linux kernel, their are Native libraries such as WebKit, OpenGL,
    FreeType, SQLite, Media, C runtime library (libc) etc.
   The WebKit library is responsible for browser support, SQLite is for database,
    FreeType for font support, Media for playing and recording audio and video
    formats.
Android App Development - Ahmad Tayeb
Android Architecture
3) Android Runtime
   In android runtime, there are core libraries and DVM (Dalvik Virtual Machine)
    which is responsible to run android application.
   DVM is like JVM but it is optimized for mobile devices. It consumes less
    memory and provides fast performance.
Android App Development - Ahmad Tayeb
Android Architecture
4) Android Framework
   On the top of Native libraries and android runtime, there is android
    framework.
   Android framework includes Android API's such as UI (User Interface),
    telephony, resources, locations, Content Providers (data) and package
    managers.
   It provides a lot of classes and interfaces for android application
    development.
Android App Development - Ahmad Tayeb
Android Architecture
5) Applications
   On the top of android framework, there are applications.
   All applications such as home, contact, settings, games, browsers are using
    android framework that uses android runtime and libraries.
   Android runtime and native libraries are using Linux kernel.
Android Core Building Blocks

   An android component is simply a piece of code that has a well defined life
    cycle e.g. Activity, Receiver, Service etc.
   The core building blocks or fundamental components of android are activities,
    views, intents, services, content providers, fragments and
    AndroidManifest.xml.
Android Core Building Blocks
Activity
   An activity is a class that represents a single screen. It is like a Frame in AWT.
Android Core Building Blocks
View
   A view is the UI element such as button, label, text field etc. Anything that
    you see is a view.
Android Core Building Blocks
Intent
   Intent is used to invoke components. It is mainly used to:
        Start the service
        Launch an activity
        Display a web page
        Display a list of contacts
        Broadcast a message
        Dial a phone call etc.
Android Core Building Blocks
Service
   Service is a background process that can
    run for a long time.
   There are two types of services local and
    remote.
   Local service is accessed from within the
    application whereas remote service is
    accessed remotely from other
    applications running on the same device.
Android Core Building Blocks
Broadcast Receiver
   Broadcast Receiver handles communication
    between Android OS and applications.
   Broadcast Receivers simply respond to
    broadcast messages from other applications
    or from the system.
   For example, applications can also initiate
    broadcasts to let other applications know
    that some data has been downloaded to the
    device and is available for them to use, so
    this is broadcast receiver who will intercept
    this communication and will initiate
    appropriate action.
Android Core Building Blocks
Content Provider
   Content Providers are used to share data between the applications.
Android Core Building Blocks
Fragment
   Fragments are like parts of activity.
   An activity can display one or more fragments on the screen at the same
    time.
Android Core Building Blocks
AndroidManifest.xml
   It contains informations about activities, content providers, permissions etc.
    It is like the web.xml file in Java EE.
Android Core Building Blocks
Android Virtual Device (AVD)
   It is used to test the android application without the need for mobile or tablet
    etc.
   It can be created in different configurations to emulate different types of real
    devices.
Prerequisites

   Android programming is based on Java programming language so if you have
    basic understanding on Java programming then it will be a fun to learn
    Android application development.
Android Studio

   Android Studio is the official IDE for android application development.
   It works based on IntelliJ IDEA.
   https://developer.android.com/studio/
Your First Android App ☺
Directory & Resource Type
Directory & Resource Type
Directory & Resource Type
Directory & Resource Type
Alternative Resources

   Your application should provide alternative resources to support specific
    device configurations.
   For example, you should include alternative drawable resources ( i.e.images )
    for different screen resolution and alternative string resources for different
    languages.
   At runtime, Android detects the current device configuration and loads the
    appropriate resources for your application.
Alternative Resources
Steps
   To specify configuration-specific alternatives for a set of resources, follow the
    following steps:
        Create a new directory in res/ named in the form -
         . Here resources_name will be any of the resources mentioned
         in the above table, like layout, drawable etc. The qualifier will specify an
         individual configuration for which these resources are to be used.
        Save the respective alternative resources in this new directory. The resource files
         must be named exactly the same as the default resource files, but these files will
         have content specific to the alternative. For example though image file name will
         be same but for high resolution screen, its resolution will be high.
Alternative Resources
Configuration Qualifier Names
   Android supports several configuration qualifiers and you can add multiple
    qualifiers to one directory name, by separating each qualifier with a dash.
   https://developer.android.com/guide/topics/resources/providing-resources
Android Activity Lifecycle
Intents

   An Intent is a messaging object you can use to request an action from
    another app component.
   Although intents facilitate communication between components in
    several ways, there are three fundamental use cases:
        Starting an activity
        Starting a service
        Delivering a broadcast
   There are two types of intents:
        Explicit intents
        Implicit intents
Intents Types
Explicit Intents
   Explicit intents specify which application will satisfy the intent, by supplying
    either the target app's package name or a fully-qualified component class
    name.
   You'll typically use an explicit intent to start a component in your own app,
    because you know the class name of the activity or service you want to start.
    For example, you might start a new activity within your app in response to a
    user action, or start a service to download a file in the background.
Intents Types
Implicit Intents
   Implicit intents do not name a specific component, but instead declare a
    general action to perform, which allows a component from another app to
    handle it.
   For example, if you want to show the user a location on a map, you can use
    an implicit intent to request that another capable app show a specified
    location on a map.
References

   https://www.techotopia.com/index.php/Handling_Android_Activity_State_Change
    s
   https://developer.android.com/guide/topics/resources/providing-resources
   https://developer.android.com/guide/components/intents-filters
   http://donkcowan.com/blog/2013/4/21/android-activity-lifecycle-method-
    typical-uses
   https://www.javatpoint.com/android-tutorial
   https://www.tutorialspoint.com/android
   https://www.devglan.com/android/android-service-example
   https://devcfgc.com/introduction-to-android-content-providers-685ed2468935
   Head First Android Development: A Brain-Friendly Guide 1st Edition, By Dawn
    Griffiths.
You can also read