• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Developing Applications for Android - Lecture#3
 

Developing Applications for Android - Lecture#3

on

  • 862 views

3rd Lecture on Developing Applications for Android.

3rd Lecture on Developing Applications for Android.

Statistics

Views

Total Views
862
Views on SlideShare
861
Embed Views
1

Actions

Likes
0
Downloads
56
Comments
1

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Thanks for sharing...
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Developing Applications for Android - Lecture#3 Developing Applications for Android - Lecture#3 Presentation Transcript

    • 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 ● Lets 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. ○ Lets 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. Lets 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. Lets 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() ● Lets have a look at code in Eclipse and view the diagram in next slide.Muhammad Usman Chaudhry CS4615 SZABIST
    • Android Activity LifecycleMuhammad Usman Chaudhry CS4615 SZABIST
    • Activity Lifecycle ● Lets implement the activity lifecycle on Eclipse.Muhammad Usman Chaudhry CS4615 SZABIST
    • Creating and Managing AVDs● Lets create AVDs and run our application on Virtual Device.Muhammad Usman Chaudhry CS4615 SZABIST
    • Running on Real Device● Running our application● Enabling debugging supportMuhammad Usman Chaudhry CS4615 SZABIST
    • Debugging● Try-It-On-Eclipse: ○ Normal Debugging ○ Logcat ○ DDMS ○ adbMuhammad Usman Chaudhry CS4615 SZABIST
    • Lets Discuss About ● View ● Fragment ● Intent ● Content Provider ● ServiceMuhammad 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 well study it later. ● Fragments are more targeted towards tablet applications. ● Lets have a look at its design philosophy.Muhammad Usman Chaudhry CS4615 SZABIST
    • FragmentMuhammad 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. ● Lets have a look at intent.Muhammad Usman Chaudhry CS4615 SZABIST
    • Content Provider ● Standard mechanism to share data among applications. ● It doesnt 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 RemoteMuhammad Usman Chaudhry CS4615 SZABIST
    • Whats Version Control & Why We Need It? ● Version control is the management of changes to the source files. ● Its 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. ● Lets 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 ● Lets 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 eventsMuhammad 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! ● Well learn to use all the controls.Muhammad Usman Chaudhry CS4615 SZABIST