ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Developing Applications
   for Android

    Muhammad Usman Chaudhry
         SZABIST CS4615




                              Lecture # 3
Today
    ¡ñ Setting up your development Environment
      ¡ð Eclipse
      ¡ð Android SDK
      ¡ð Android Development Tools (ADT)
    ¡ñ Creating HelloWorld Application
    ¡ñ File Structure
      ¡ð AndroidManifest.xml, src, assets, res, bin, gen, etc.
    ¡ñ Activity Lifecycle
      ¡ð onCreate, onStart, onRestart, onResume, onPause,
          onStop, onDestroy
    ¡ñ A program to study Lifecycle behavior.



Muhammad Usman Chaudhry       CS4615                        SZABIST
Today
    ¡ñ Android Virtual Devices (AVD)
      ¡ð Creating & Launching Virtual Devices/Emulator
    ¡ñ Running applications on Real Device
    ¡ñ Debugging
      ¡ð DDMS
      ¡ð adb
      ¡ð Normal debugging
      ¡ð Using LogCat
    ¡ñ Basics About
      ¡ð View, Fragment, Intent, Content Provider, Service
    ¡ñ Learning about VCS, DVCS, Git & Hg.
    ¡ñ Using Hg/Bitbucket as version control & how-to, clone,
      pull, commit and push code changes.

Muhammad Usman Chaudhry       CS4615                       SZABIST
Setting Up IDE
    ¡ñ Download Eclipse (http://eclipse.org/downloads - Eclipse
      Classic 4.2)
    ¡ñ Download & Installing Android SDK (http://developer.
      android.com/sdk)
    ¡ñ Configuring Platform APIs (Via SDK Manager)
    ¡ñ Installing ADT Plugin (https://dl-ssl.google.
      com/android/eclipse)




Muhammad Usman Chaudhry       CS4615                       SZABIST
Hello World Android
    ¡ñ Let's create and discuss HelloWorld
      Application.




Muhammad Usman Chaudhry   CS4615            SZABIST
File Structure
    ¡ñ AndroidManifest.xml:
      ¡ð This file manages, Icons, Labels,
         Permissions, Libraries, Intent Filters and
         many other configuration parameters
         related to application.
      ¡ð Let's have a look and discuss basics of
         Manifest file in Eclipse.
    ¡ñ src:
      ¡ð Contains all the source packages, activity
         and non-activity Java class files.

Muhammad Usman Chaudhry   CS4615                      SZABIST
File Structure
    ¡ñ assets:
      ¡ð Used to store raw data.
      ¡ð Example would be textures, game data,
         static html/xml/json files etc.
      ¡ð Can access via AssetManager
    ¡ñ libs: Contain private libraries.
    ¡ñ bin: Contain compiled resources. (APK etc.)
    ¡ñ gen: Generated Java files. (R.java etc.)
    ¡ñ jni: Native code sources, developed using NDK.



Muhammad Usman Chaudhry   CS4615                  SZABIST
File Structure
    ¡ñ res:
        ¡ð Contain all application resources
        ¡ð Include most of the following directories:
          ¡ö anim - for xml files that are compiled
             into Animation objects.
          ¡ö color - for xml files that describe colors.
          ¡ö drawable - for images, drawable
             resource types like BMP,JPG, 9-patch
             etc. Let's discuss more about drawable
             over Eclipse.

Muhammad Usman Chaudhry     CS4615                   SZABIST
File Structure

             ¡ö layout - XML files compiled into screen
               objects/views.
             ¡ö menu - XML files defining application
               menus.
             ¡ö raw - Same as assets, except it can be
               accessed via R file.
             ¡ö values - XML files containing string
               values. Let's see how its used.
             ¡ö xml - Other xml files, eg.
               PreferenceScreen, etc.

Muhammad Usman Chaudhry      CS4615                      SZABIST
Android Activity Lifecycle

    ¡ñ Activity instances in our apps transition between various
      states whenever a user interacts with the application.
    ¡ñ Mostly these events are called in following order:
       ¡ð onCreate(Bundle savedInstanceState)
       ¡ð onStart()
       ¡ð onResume()
       ¡ð onPause()
       ¡ð onRestart()
       ¡ð onStop()
       ¡ð onDestroy()
    ¡ñ Let's have a look at code in Eclipse and view the diagram
      in next slide.


Muhammad Usman Chaudhry        CS4615                        SZABIST
Android Activity Lifecycle




Muhammad Usman Chaudhry   CS4615   SZABIST
Activity Lifecycle
    ¡ñ Let's implement the activity lifecycle on
      Eclipse.




Muhammad Usman Chaudhry   CS4615                  SZABIST
Creating and Managing AVDs
¡ñ Let's create AVDs and run our application on
  Virtual Device.




Muhammad Usman Chaudhry   CS4615                 SZABIST
Running on Real Device
¡ñ Running our application
¡ñ Enabling debugging support




Muhammad Usman Chaudhry   CS4615   SZABIST
Debugging
¡ñ Try-It-On-Eclipse:
     ¡ð   Normal Debugging
     ¡ð   Logcat
     ¡ð   DDMS
     ¡ð   adb




Muhammad Usman Chaudhry     CS4615   SZABIST
Let's Discuss About
    ¡ñ   View
    ¡ñ   Fragment
    ¡ñ   Intent
    ¡ñ   Content Provider
    ¡ñ   Service




Muhammad Usman Chaudhry    CS4615   SZABIST
View
    ¡ñ View represents the basic building block for UI components.
    ¡ñ All the controls within android are direct or indirect
      subclasses of View.
    ¡ñ We may extend View or even its subclasses to create
      custom controls.
    ¡ñ Examples are:
       ¡ð Direct Subclasses:
           ¡ö ImageView
           ¡ö TextView
           ¡ö And many other...
       ¡ð Indirect Subclasses:
           ¡ö Button
           ¡ö ListView
           ¡ö And many more...
Muhammad Usman Chaudhry        CS4615                         SZABIST
Fragment
    ¡ñ A fragment represents a behavior or a
      portion of user interface in an activity.
    ¡ñ You may combine multiple fragments in a
      single activity to build a multi-pane UI.
    ¡ñ Fragment have lifecycle of its own, but
      we'll study it later.
    ¡ñ Fragments are more targeted towards
      tablet applications.
    ¡ñ Let's have a look at its design philosophy.

Muhammad Usman Chaudhry   CS4615                    SZABIST
Fragment




Muhammad Usman Chaudhry   CS4615   SZABIST
Intent
    ¡ñ More like an 'intention' to do some work.
    ¡ñ Intents are used to:
      ¡ð Broadcast a message
      ¡ð Start a service
      ¡ð Launch an activity
      ¡ð Display a web page
      ¡ð Dial a phone number
    ¡ñ Intents can be explicit or implicit.
    ¡ñ Let's have a look at intent.

Muhammad Usman Chaudhry   CS4615                  SZABIST
Content Provider
    ¡ñ Standard mechanism to share data among
      applications.
    ¡ñ It doesn't expose underlying storage,
      structure and implementation.
    ¡ñ Your application can expose data to other
      applications or even read the data shared
      by other applications.



Muhammad Usman Chaudhry   CS4615                  SZABIST
Service
    ¡ñ Background processes that runs for long
      time.
    ¡ñ Android has 2 type of services:
      ¡ð Local Services:
         ¡ö Only used by the application that is hosting it.
      ¡ð Remote Services:
         ¡ö Accessible by other applications as well.
    ¡ñ Local Vs Remote


Muhammad Usman Chaudhry       CS4615                      SZABIST
What's Version Control & Why We Need It?

    ¡ñ Version control is the management of
      changes to the source files.
    ¡ñ It's used to keep track of who did what and
      when in the code.
    ¡ñ In case of problem in latest code, you can
      easily revert back to any past version.
    ¡ñ Easier to collaborate and track the code
      changes among programmers working on
      the same project and files.

Muhammad Usman Chaudhry   CS4615                SZABIST
Standard Version Control System

    ¡ñ Usually a central server.
    ¡ñ A programmer may check-out a file, work
      over it and checks-in back.
    ¡ñ When a programmer has checked the file
      out, no other programmers can make
      changes to that particular file.
    ¡ñ Famous framework is SVN, CVS etc.



Muhammad Usman Chaudhry   CS4615                SZABIST
DVCS
    Distributed Version Control System

    ¡ñ Instead of centralized system it uses P2P.
    ¡ñ Avoids single point of failure.
    ¡ñ Allow users to check-in and merge the code
      anytime they want to.
    ¡ñ Famous frameworks are Hg(Mercurial) and
      Git.
    ¡ñ Let's watch this video to get more detailed
      idea:
      ¡ð http://www.fogcreek.com/kiln/

Muhammad Usman Chaudhry   CS4615               SZABIST
Mercurial & Git
    ¡ñ Mercurial (Hg) & Git are 2 leading
      frameworks used for Revision Control.
    ¡ñ Basic difference is,
         ¡ð git provide set of tools like git-pull, git-push, etc.
         ¡ð Hg is monolithic and all in one.
    ¡ñ Both have almost identical features.
    ¡ñ We prefer Mercurial, due to easier learning
      curve.



Muhammad Usman Chaudhry          CS4615                         SZABIST
Using Hg & BB
    ¡ñ Installing Hg
    ¡ñ Let's create a repository at Bitbucket (BB) Source
      code hosting site.
    ¡ñ Create a local repository. (hg init)
    ¡ñ Add Files. (hg add .)
    ¡ñ Commit changes (hg commit -m "first")
    ¡ñ Push our changes to BB. (hg push REPO-URL)
    ¡ñ Remember repeat cycle
      ¡ð Pull - Update - Merge/Resolve - Commit - Push
    ¡ñ Adding users to BB & using (hg clone to get current
      copy).
    ¡ñ We shall look into branching etc. later.
Muhammad Usman Chaudhry      CS4615                     SZABIST
Lab Tasks Today
    ¡ñ Setup Android Development Environment
    ¡ñ Create HelloWorld Application
    ¡ñ Create AVDs
    ¡ñ Run your application in at least 2 different
      AVDs
    ¡ñ Create Lifecycle Activity Application
    ¡ñ Log all lifecycle events



Muhammad Usman Chaudhry   CS4615                 SZABIST
Lab Tasks Today
    ¡ñ Setup Hg on System, create Bitbucket account.
    ¡ñ Create a group of 2, invite your partner so he/she
      could clone the code, make changes and pass
      through the following Steps:
      ¡ð init-add-commit-push (For you)
      ¡ð clone (For other group partner)
      ¡ð //Make certain changes
      ¡ð pull-update-commit-push (For other group
         partner)
      ¡ð //Make certain changes
      ¡ð pull-update-commit-push (For you)

Muhammad Usman Chaudhry      CS4615                        SZABIST
Coming Up Next
    ¡ñ Detail in Design!
    ¡ñ We'll learn to use all the controls.




Muhammad Usman Chaudhry       CS4615         SZABIST

More Related Content

Similar to Developing Applications for Android - Lecture#3 (20)

The Ultimate Android Security Checklist (Mdevcon 2014)
The Ultimate Android Security Checklist (Mdevcon 2014)The Ultimate Android Security Checklist (Mdevcon 2014)
The Ultimate Android Security Checklist (Mdevcon 2014)
Ron Munitz
?
The Ultimate Android Security Checklist (AnDevCon Boston 2014)
The Ultimate Android Security Checklist (AnDevCon Boston 2014)The Ultimate Android Security Checklist (AnDevCon Boston 2014)
The Ultimate Android Security Checklist (AnDevCon Boston 2014)
Ron Munitz
?
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
niallo
?
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JSFestUA
?
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Codemotion
?
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
Vlad Fedosov
?
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
Ron Munitz
?
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
?
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
?
CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering lab
Ron Munitz
?
Progressive Web App Testing With Cypress.io
Progressive Web App Testing With Cypress.ioProgressive Web App Testing With Cypress.io
Progressive Web App Testing With Cypress.io
Knoldus Inc.
?
Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
Teleport
?
Pentester++
Pentester++Pentester++
Pentester++
CTruncer
?
Getting started with docker (2017)
Getting started with docker (2017)Getting started with docker (2017)
Getting started with docker (2017)
JEMLI Fathi
?
MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows
Ron Munitz
?
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
?
Headless Android
Headless AndroidHeadless Android
Headless Android
Opersys inc.
?
Drools & jBPM Workshop Barcelona 2013
Drools & jBPM Workshop  Barcelona 2013Drools & jBPM Workshop  Barcelona 2013
Drools & jBPM Workshop Barcelona 2013
Mauricio (Salaboy) Salatino
?
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
?
Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)
Ron Munitz
?
The Ultimate Android Security Checklist (Mdevcon 2014)
The Ultimate Android Security Checklist (Mdevcon 2014)The Ultimate Android Security Checklist (Mdevcon 2014)
The Ultimate Android Security Checklist (Mdevcon 2014)
Ron Munitz
?
The Ultimate Android Security Checklist (AnDevCon Boston 2014)
The Ultimate Android Security Checklist (AnDevCon Boston 2014)The Ultimate Android Security Checklist (AnDevCon Boston 2014)
The Ultimate Android Security Checklist (AnDevCon Boston 2014)
Ron Munitz
?
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
niallo
?
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. §£§Ý§Ñ§Õ §¶§Ö§Õ§à§ã§à§Ó. Technology agnostic microservices at SPA f...
JSFestUA
?
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Ron Munitz - The Ultimate Android Security Checklist - Codemotion Rome 2015
Codemotion
?
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
Vlad Fedosov
?
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
The Ultimate Android Security Checklist (Codemotion Tel-Aviv, 2014)
Ron Munitz
?
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
?
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
?
CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering lab
Ron Munitz
?
Progressive Web App Testing With Cypress.io
Progressive Web App Testing With Cypress.ioProgressive Web App Testing With Cypress.io
Progressive Web App Testing With Cypress.io
Knoldus Inc.
?
Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
Teleport
?
Getting started with docker (2017)
Getting started with docker (2017)Getting started with docker (2017)
Getting started with docker (2017)
JEMLI Fathi
?
MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows
Ron Munitz
?
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
?
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
?
Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)
Ron Munitz
?

Recently uploaded (20)

Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
?
Solana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdfSolana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdf
Lisa ward
?
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
NTTDOCOMO-ServiceInnovation
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AIGDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
James Anderson
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-WorldAll-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
Safe Software
?
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
?
Columbia Weather Systems - Product Overview
Columbia Weather Systems - Product OverviewColumbia Weather Systems - Product Overview
Columbia Weather Systems - Product Overview
Columbia Weather Systems
?
Top Tips to Get Your Data AI-Ready? ? ?? ?
Top Tips to Get Your Data AI-Ready? ? ?? ?Top Tips to Get Your Data AI-Ready? ? ?? ?
Top Tips to Get Your Data AI-Ready? ? ?? ?
Precisely
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
The effectiveness of ai powered educational tools in enhancing academic perfo...
The effectiveness of ai powered educational tools in enhancing academic perfo...The effectiveness of ai powered educational tools in enhancing academic perfo...
The effectiveness of ai powered educational tools in enhancing academic perfo...
aebhpmqaocxhydmajf
?
Build Your Uber Clone App with Advanced Features
Build Your Uber Clone App with Advanced FeaturesBuild Your Uber Clone App with Advanced Features
Build Your Uber Clone App with Advanced Features
V3cube
?
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
?
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptxHHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HampshireHUG
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
?
Solana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdfSolana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdf
Lisa ward
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AIGDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
James Anderson
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-WorldAll-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
Safe Software
?
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
?
Top Tips to Get Your Data AI-Ready? ? ?? ?
Top Tips to Get Your Data AI-Ready? ? ?? ?Top Tips to Get Your Data AI-Ready? ? ?? ?
Top Tips to Get Your Data AI-Ready? ? ?? ?
Precisely
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
The effectiveness of ai powered educational tools in enhancing academic perfo...
The effectiveness of ai powered educational tools in enhancing academic perfo...The effectiveness of ai powered educational tools in enhancing academic perfo...
The effectiveness of ai powered educational tools in enhancing academic perfo...
aebhpmqaocxhydmajf
?
Build Your Uber Clone App with Advanced Features
Build Your Uber Clone App with Advanced FeaturesBuild Your Uber Clone App with Advanced Features
Build Your Uber Clone App with Advanced Features
V3cube
?
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptxHHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HHUG-04-2025-Close-more-deals-from-your-existing-pipeline-FOR SLIDESHARE.pptx
HampshireHUG
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?

Developing Applications for Android - Lecture#3

  • 1. Developing Applications for Android Muhammad Usman Chaudhry SZABIST CS4615 Lecture # 3
  • 2. Today ¡ñ Setting up your development Environment ¡ð Eclipse ¡ð Android SDK ¡ð Android Development Tools (ADT) ¡ñ Creating HelloWorld Application ¡ñ File Structure ¡ð AndroidManifest.xml, src, assets, res, bin, gen, etc. ¡ñ Activity Lifecycle ¡ð onCreate, onStart, onRestart, onResume, onPause, onStop, onDestroy ¡ñ A program to study Lifecycle behavior. Muhammad Usman Chaudhry CS4615 SZABIST
  • 3. Today ¡ñ Android Virtual Devices (AVD) ¡ð Creating & Launching Virtual Devices/Emulator ¡ñ Running applications on Real Device ¡ñ Debugging ¡ð DDMS ¡ð adb ¡ð Normal debugging ¡ð Using LogCat ¡ñ Basics About ¡ð View, Fragment, Intent, Content Provider, Service ¡ñ Learning about VCS, DVCS, Git & Hg. ¡ñ Using Hg/Bitbucket as version control & how-to, clone, pull, commit and push code changes. Muhammad Usman Chaudhry CS4615 SZABIST
  • 4. Setting Up IDE ¡ñ Download Eclipse (http://eclipse.org/downloads - Eclipse Classic 4.2) ¡ñ Download & Installing Android SDK (http://developer. android.com/sdk) ¡ñ Configuring Platform APIs (Via SDK Manager) ¡ñ Installing ADT Plugin (https://dl-ssl.google. com/android/eclipse) Muhammad Usman Chaudhry CS4615 SZABIST
  • 5. Hello World Android ¡ñ Let's create and discuss HelloWorld Application. Muhammad Usman Chaudhry CS4615 SZABIST
  • 6. File Structure ¡ñ AndroidManifest.xml: ¡ð This file manages, Icons, Labels, Permissions, Libraries, Intent Filters and many other configuration parameters related to application. ¡ð Let's have a look and discuss basics of Manifest file in Eclipse. ¡ñ src: ¡ð Contains all the source packages, activity and non-activity Java class files. Muhammad Usman Chaudhry CS4615 SZABIST
  • 7. File Structure ¡ñ assets: ¡ð Used to store raw data. ¡ð Example would be textures, game data, static html/xml/json files etc. ¡ð Can access via AssetManager ¡ñ libs: Contain private libraries. ¡ñ bin: Contain compiled resources. (APK etc.) ¡ñ gen: Generated Java files. (R.java etc.) ¡ñ jni: Native code sources, developed using NDK. Muhammad Usman Chaudhry CS4615 SZABIST
  • 8. File Structure ¡ñ res: ¡ð Contain all application resources ¡ð Include most of the following directories: ¡ö anim - for xml files that are compiled into Animation objects. ¡ö color - for xml files that describe colors. ¡ö drawable - for images, drawable resource types like BMP,JPG, 9-patch etc. Let's discuss more about drawable over Eclipse. Muhammad Usman Chaudhry CS4615 SZABIST
  • 9. File Structure ¡ö layout - XML files compiled into screen objects/views. ¡ö menu - XML files defining application menus. ¡ö raw - Same as assets, except it can be accessed via R file. ¡ö values - XML files containing string values. Let's see how its used. ¡ö xml - Other xml files, eg. PreferenceScreen, etc. Muhammad Usman Chaudhry CS4615 SZABIST
  • 10. Android Activity Lifecycle ¡ñ Activity instances in our apps transition between various states whenever a user interacts with the application. ¡ñ Mostly these events are called in following order: ¡ð onCreate(Bundle savedInstanceState) ¡ð onStart() ¡ð onResume() ¡ð onPause() ¡ð onRestart() ¡ð onStop() ¡ð onDestroy() ¡ñ Let's have a look at code in Eclipse and view the diagram in next slide. Muhammad Usman Chaudhry CS4615 SZABIST
  • 11. Android Activity Lifecycle Muhammad Usman Chaudhry CS4615 SZABIST
  • 12. Activity Lifecycle ¡ñ Let's implement the activity lifecycle on Eclipse. Muhammad Usman Chaudhry CS4615 SZABIST
  • 13. Creating and Managing AVDs ¡ñ Let's create AVDs and run our application on Virtual Device. Muhammad Usman Chaudhry CS4615 SZABIST
  • 14. Running on Real Device ¡ñ Running our application ¡ñ Enabling debugging support Muhammad Usman Chaudhry CS4615 SZABIST
  • 15. Debugging ¡ñ Try-It-On-Eclipse: ¡ð Normal Debugging ¡ð Logcat ¡ð DDMS ¡ð adb Muhammad Usman Chaudhry CS4615 SZABIST
  • 16. Let's Discuss About ¡ñ View ¡ñ Fragment ¡ñ Intent ¡ñ Content Provider ¡ñ Service Muhammad Usman Chaudhry CS4615 SZABIST
  • 17. View ¡ñ View represents the basic building block for UI components. ¡ñ All the controls within android are direct or indirect subclasses of View. ¡ñ We may extend View or even its subclasses to create custom controls. ¡ñ Examples are: ¡ð Direct Subclasses: ¡ö ImageView ¡ö TextView ¡ö And many other... ¡ð Indirect Subclasses: ¡ö Button ¡ö ListView ¡ö And many more... Muhammad Usman Chaudhry CS4615 SZABIST
  • 18. Fragment ¡ñ A fragment represents a behavior or a portion of user interface in an activity. ¡ñ You may combine multiple fragments in a single activity to build a multi-pane UI. ¡ñ Fragment have lifecycle of its own, but we'll study it later. ¡ñ Fragments are more targeted towards tablet applications. ¡ñ Let's have a look at its design philosophy. Muhammad Usman Chaudhry CS4615 SZABIST
  • 20. Intent ¡ñ More like an 'intention' to do some work. ¡ñ Intents are used to: ¡ð Broadcast a message ¡ð Start a service ¡ð Launch an activity ¡ð Display a web page ¡ð Dial a phone number ¡ñ Intents can be explicit or implicit. ¡ñ Let's have a look at intent. Muhammad Usman Chaudhry CS4615 SZABIST
  • 21. Content Provider ¡ñ Standard mechanism to share data among applications. ¡ñ It doesn't expose underlying storage, structure and implementation. ¡ñ Your application can expose data to other applications or even read the data shared by other applications. Muhammad Usman Chaudhry CS4615 SZABIST
  • 22. Service ¡ñ Background processes that runs for long time. ¡ñ Android has 2 type of services: ¡ð Local Services: ¡ö Only used by the application that is hosting it. ¡ð Remote Services: ¡ö Accessible by other applications as well. ¡ñ Local Vs Remote Muhammad Usman Chaudhry CS4615 SZABIST
  • 23. What's Version Control & Why We Need It? ¡ñ Version control is the management of changes to the source files. ¡ñ It's used to keep track of who did what and when in the code. ¡ñ In case of problem in latest code, you can easily revert back to any past version. ¡ñ Easier to collaborate and track the code changes among programmers working on the same project and files. Muhammad Usman Chaudhry CS4615 SZABIST
  • 24. Standard Version Control System ¡ñ Usually a central server. ¡ñ A programmer may check-out a file, work over it and checks-in back. ¡ñ When a programmer has checked the file out, no other programmers can make changes to that particular file. ¡ñ Famous framework is SVN, CVS etc. Muhammad Usman Chaudhry CS4615 SZABIST
  • 25. DVCS Distributed Version Control System ¡ñ Instead of centralized system it uses P2P. ¡ñ Avoids single point of failure. ¡ñ Allow users to check-in and merge the code anytime they want to. ¡ñ Famous frameworks are Hg(Mercurial) and Git. ¡ñ Let's watch this video to get more detailed idea: ¡ð http://www.fogcreek.com/kiln/ Muhammad Usman Chaudhry CS4615 SZABIST
  • 26. Mercurial & Git ¡ñ Mercurial (Hg) & Git are 2 leading frameworks used for Revision Control. ¡ñ Basic difference is, ¡ð git provide set of tools like git-pull, git-push, etc. ¡ð Hg is monolithic and all in one. ¡ñ Both have almost identical features. ¡ñ We prefer Mercurial, due to easier learning curve. Muhammad Usman Chaudhry CS4615 SZABIST
  • 27. Using Hg & BB ¡ñ Installing Hg ¡ñ Let's create a repository at Bitbucket (BB) Source code hosting site. ¡ñ Create a local repository. (hg init) ¡ñ Add Files. (hg add .) ¡ñ Commit changes (hg commit -m "first") ¡ñ Push our changes to BB. (hg push REPO-URL) ¡ñ Remember repeat cycle ¡ð Pull - Update - Merge/Resolve - Commit - Push ¡ñ Adding users to BB & using (hg clone to get current copy). ¡ñ We shall look into branching etc. later. Muhammad Usman Chaudhry CS4615 SZABIST
  • 28. Lab Tasks Today ¡ñ Setup Android Development Environment ¡ñ Create HelloWorld Application ¡ñ Create AVDs ¡ñ Run your application in at least 2 different AVDs ¡ñ Create Lifecycle Activity Application ¡ñ Log all lifecycle events Muhammad Usman Chaudhry CS4615 SZABIST
  • 29. Lab Tasks Today ¡ñ Setup Hg on System, create Bitbucket account. ¡ñ Create a group of 2, invite your partner so he/she could clone the code, make changes and pass through the following Steps: ¡ð init-add-commit-push (For you) ¡ð clone (For other group partner) ¡ð //Make certain changes ¡ð pull-update-commit-push (For other group partner) ¡ð //Make certain changes ¡ð pull-update-commit-push (For you) Muhammad Usman Chaudhry CS4615 SZABIST
  • 30. Coming Up Next ¡ñ Detail in Design! ¡ñ We'll learn to use all the controls. Muhammad Usman Chaudhry CS4615 SZABIST