SlideShare a Scribd company logo
1 of 59
Lecture 3 agenda
Layouts
Intents (both explicit and implicit)
ListViews and Adapters
Layouts in Android
6/9/12
layout_margin (layout means in relation to parent)
padding
6/9/12
6/9/12
SP scale independent pixels respects the users' settings for font size.
6/9/12
6/9/12
6/9/12
(layout means in relation to parent)
6/9/12
6/9/12
weight
6/9/12
FrameLayout
6/9/12
6/9/12
6/9/12
6/9/12
6/9/12
6/9/12
6/9/12
6/9/12
6/9/12
Fragments...what good are they?
Intents
From Google: An Intent object is a bundle of
information. It contains information of interest
to the component that receives the intent
(such as the action to be taken and the data to
act on) plus information of interest to the
Android system (such as the category of
component that should handle the intent and
instructions on how to launch a target activity)
Activated by Intents
Activities
Services
Broadcast Receivers (aka Receivers)
(http://developer.android.com/guide/componen
ts/intents-filters.html)
Explicit Intent
//Explicit; all you need is the Context and the target class
Intent itn = new Intent(this, ResultActivity.class);
ResultActivity.class
Explicit
Explicit Intent
//Explicit; all you need is the packageContext and the target
class
Intent itn = new Intent(this, ResultActivity.class);
itn.putExtra(QuizActivity.CORRECT, mCorrect);
itn.putExtra(QuizActivity.INCORRECT, mIncorrect);
itn.putExtra(QuizActivity.NAME, mName);
CORRECT: 5
INCORRECT: 3
PLAYER: Adam
ResultActivit
y.class
Explicit
Intent Architecture::Action/Data/etc
//Explicit; all you need is the ComponentName and optionally
the bundle.
//Implicit; usually Action/Data and then optionally the
bundle.
name : Adam Gerber
email : gerber@cs.uchicago.edu
ret : something...
Action
Data
Scheme
Categories
ComponentName
Explicit
Implicit
Explicit Intents: intra-app call by name
//********************************
//This method works great for intra-app calls between activities
//********************************
//use the calling class and the called class as params to constructor.
Intent itn = new Intent(this, Second.class);
startActivity(itn);
//
Explicit Intents: intra-app call by name
Intent itnThird = new Intent(this, ThirdActivity.class);
itnThird.putExtra("name", "Adam Gerber");
itnThird.putExtra("email", "gerber@cs.uchicago.edu");
startActivity(itnThird);
Implicit Intents: inter-app call
Intent itn = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com/"));
startActivity(itn);
Implicit intents are anonymous and loosely-coupled.
You request the component like a service of the
operating system.
Implicit Intents: Action/Data pairs
ACTION_VIEW content://contacts/people/1 -- Display information about
the person whose identifier is "1".
ACTION_DIAL content://contacts/people/1 -- Display the phone dialer with
the person filled in.
ACTION_VIEW tel:123 -- Display the phone dialer with the given number
filled in. Note how the VIEW action does what what is considered the most
reasonable thing for a particular URI.
ACTION_DIAL tel:123 -- Display the phone dialer with the given number
filled in.
ACTION_EDIT content://contacts/people/1 -- Edit information about the
person whose identifier is "1".
ACTION_VIEW content://contacts/people/ -- Display a list of people, which
the user can browse through. This example is a typical top-level entry into
the Contacts application, showing you the list of people.
Intent Architecture::Bundle (aka extras)
//The bundle is a data structure inside the
Intent.
//It holds key/value pairs.
//Keys are always Strings, and values are
always primitives, Serializable or
Parcelable.
name : Adam Gerber
email : gerber@cs.uchicago.edu
ret : something...
Action
Data
Scheme
Categories
ComponentName
Serializable versus Parcelable
Parcelable is an Interface very much like Serializable
only it has been optimized for Android. Unlike
Serializeable, all the reflection meta-data has been
stripped-out of the parcelized object.
Intents
Intent messaging is a facility for late run-time binding
between components in the same or different
applications.
Intents are handled by the Android OS. In order for the
OS to know about a component, it must be declared
in the application manifest file.
If a component does not define Intent filters, it can only
be called by explicit Intents. A component with filters
can receive both explicit and implicit intents.
6/12/12
AndroidManifest.xml file
Is an inventory of all the components in an
application.
If the component is not listed there, the Android
OS won't know it's there. Not even intra-app
component communication will resolve.
6/12/12
Android OS
A
*A
I
AndroidManifest.xml
A
*A
Categories
//Use Categories to further refine your
Intent
//Most important is CATEGORY_DEFAULT
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
ListViews and Adapters
Adapters
AdapterViews
Resources in Android
Layouts and resources
Code: Java (or C if you use NDK)
Metafiles: AndroidManifest, project.properties,
.gitignore. These all describe the project.
Resources “anything in android that is not code or
metafiles”
Activities have one or more layouts, and all Layouts
have a root-ViewGroup. This root-ViewGroup is the
container for the Views.
R.java (gen directory) is a bridge between your
resources and your code. If you want to interact
programmatically with a resource, it must have an id.
Inspecting layouts and resources
You can view both xml and design mode in AS.
You can see how it would look on multiple devices ||
preview all screens, and toggle with remove previews.
Layouts and resources
res directories can have suffixes, such as layout-land, or
drawable-hdpi, values-es, etc.
These suffixes allow you to differentiate at RUNTIME
depending on the settings, hardware, and configuration
of the device.
For example, if your device is in landscape mode, it'll try
to fetch the layout from layout-land first, then it will try
to fetch the layout from layout. Vice versa as well; if it's
in portait mode, it'll try for layout-port, then layout.
shown in preview mode of resource and rotate device
Lifecycle in Android
how to copy files from a bc branch to a lb branch
Actions || Open in Terminal
git checkout c7c7 res/drawable-*/.
git checkout c7c7 res/values/str*
before a commit you may remove from stage, then:
discard: for existing files that you want to roll back
remove: for new files that you want to delete
ADB (Android Device Bridge)
adb kill-server
adb start-server
adb get-state
adb devices
Use kill-server / start-server to reboot the adb if your device/emulator is not
communicating with your dev-machine.
Navigating in Android Studio
alt-1 is project view (alt-F1 is show it in project view)
alt-2 is favorites (including bookmarks and breakpoints)
alt-3 is the search view (cntl-shift-F to find)
alt-4 run-console
alt-5 is debug
alt-6 is android view (ddms, logcat)
alt-7 is structure view (see members and methods)
alt-9 is changes(VCS) view
Look at the margin of your project
Get help
cntl-shift-A (find anything in Android studio)
Searching (on mac, replace cntrl with command)
cntl-F (find something in the local file)
cntl-shift-F (find something in the project)
Go to file in code (on mac, replace cntrl with command)
cntl-N (go to files typically in src)
cntl-shift-n (go to any file, including res)
cntl-E (open recent files)
Go to file in project
alt-F1
Go to definition
cntl-B (go directly to the method definition)
Javadocs
cntl-Q (open the javadocs)
Live Templates
cntl-J
adding your own Live Templates (cntl-shift-A “live
template”)
Debugging
Using the debugger (alt-5)
See bookmarks and breakpoints (alt-2)
F11 to toggle bookmark
Using logcat (alt-6)
Using lint and AS analyzer: Analyze || Inspect Code
///TODO this is my todo message

More Related Content

Similar to Lecture-3.ppt

Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Interface Programming Android
Interface Programming AndroidInterface Programming Android
Interface Programming AndroidMaksym Davydov
 
Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Java talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentJava talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentAlexei Miliutin
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsMaksym Davydov
 
Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android ApplicationArcadian Learning
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Amit Saxena
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application DevelopmentAbelRobel
 

Similar to Lecture-3.ppt (20)

Android dev
Android devAndroid dev
Android dev
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Interface Programming Android
Interface Programming AndroidInterface Programming Android
Interface Programming Android
 
Hello android world
Hello android worldHello android world
Hello android world
 
Java talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentJava talks. Android intoduction for develompment
Java talks. Android intoduction for develompment
 
Android overview
Android overviewAndroid overview
Android overview
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile Apps
 
Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android Application
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Best android classes in mumbai
Best android classes in mumbaiBest android classes in mumbai
Best android classes in mumbai
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android-Tutorial.ppt
Android-Tutorial.pptAndroid-Tutorial.ppt
Android-Tutorial.ppt
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 

More from ShivamChaturvedi67 (16)

ddc cinverter control design process.ppt
ddc cinverter control design process.pptddc cinverter control design process.ppt
ddc cinverter control design process.ppt
 
ffCCMPFCInductorDesignwithPowderCore.ppt
ffCCMPFCInductorDesignwithPowderCore.pptffCCMPFCInductorDesignwithPowderCore.ppt
ffCCMPFCInductorDesignwithPowderCore.ppt
 
transformer-and-dc-motor control designs
transformer-and-dc-motor control designstransformer-and-dc-motor control designs
transformer-and-dc-motor control designs
 
magnetism_qr.pptx
magnetism_qr.pptxmagnetism_qr.pptx
magnetism_qr.pptx
 
Update7622.pptx
Update7622.pptxUpdate7622.pptx
Update7622.pptx
 
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
 
02_Design.pptx
02_Design.pptx02_Design.pptx
02_Design.pptx
 
Education_selecting key discovery tools for education research_v1_2021.pptx
Education_selecting key discovery tools for education research_v1_2021.pptxEducation_selecting key discovery tools for education research_v1_2021.pptx
Education_selecting key discovery tools for education research_v1_2021.pptx
 
Ch05.pdf
Ch05.pdfCh05.pdf
Ch05.pdf
 
Ch05-converted.pptx
Ch05-converted.pptxCh05-converted.pptx
Ch05-converted.pptx
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
android.ppt
android.pptandroid.ppt
android.ppt
 
1_5_Python_to_Java.pptx
1_5_Python_to_Java.pptx1_5_Python_to_Java.pptx
1_5_Python_to_Java.pptx
 
l7-pointers.ppt
l7-pointers.pptl7-pointers.ppt
l7-pointers.ppt
 
Lecture-2.ppt
Lecture-2.pptLecture-2.ppt
Lecture-2.ppt
 
Lecture-1.ppt
Lecture-1.pptLecture-1.ppt
Lecture-1.ppt
 

Recently uploaded

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 

Recently uploaded (20)

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 

Lecture-3.ppt

  • 1. Lecture 3 agenda Layouts Intents (both explicit and implicit) ListViews and Adapters
  • 3. 6/9/12 layout_margin (layout means in relation to parent) padding
  • 5. 6/9/12 SP scale independent pixels respects the users' settings for font size.
  • 8. 6/9/12 (layout means in relation to parent)
  • 22.
  • 23.
  • 24.
  • 25. From Google: An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity)
  • 26. Activated by Intents Activities Services Broadcast Receivers (aka Receivers) (http://developer.android.com/guide/componen ts/intents-filters.html)
  • 27. Explicit Intent //Explicit; all you need is the Context and the target class Intent itn = new Intent(this, ResultActivity.class); ResultActivity.class Explicit
  • 28. Explicit Intent //Explicit; all you need is the packageContext and the target class Intent itn = new Intent(this, ResultActivity.class); itn.putExtra(QuizActivity.CORRECT, mCorrect); itn.putExtra(QuizActivity.INCORRECT, mIncorrect); itn.putExtra(QuizActivity.NAME, mName); CORRECT: 5 INCORRECT: 3 PLAYER: Adam ResultActivit y.class Explicit
  • 29. Intent Architecture::Action/Data/etc //Explicit; all you need is the ComponentName and optionally the bundle. //Implicit; usually Action/Data and then optionally the bundle. name : Adam Gerber email : gerber@cs.uchicago.edu ret : something... Action Data Scheme Categories ComponentName Explicit Implicit
  • 30.
  • 31. Explicit Intents: intra-app call by name //******************************** //This method works great for intra-app calls between activities //******************************** //use the calling class and the called class as params to constructor. Intent itn = new Intent(this, Second.class); startActivity(itn); //
  • 32. Explicit Intents: intra-app call by name Intent itnThird = new Intent(this, ThirdActivity.class); itnThird.putExtra("name", "Adam Gerber"); itnThird.putExtra("email", "gerber@cs.uchicago.edu"); startActivity(itnThird);
  • 33. Implicit Intents: inter-app call Intent itn = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/")); startActivity(itn); Implicit intents are anonymous and loosely-coupled. You request the component like a service of the operating system.
  • 34. Implicit Intents: Action/Data pairs ACTION_VIEW content://contacts/people/1 -- Display information about the person whose identifier is "1". ACTION_DIAL content://contacts/people/1 -- Display the phone dialer with the person filled in. ACTION_VIEW tel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI. ACTION_DIAL tel:123 -- Display the phone dialer with the given number filled in. ACTION_EDIT content://contacts/people/1 -- Edit information about the person whose identifier is "1". ACTION_VIEW content://contacts/people/ -- Display a list of people, which the user can browse through. This example is a typical top-level entry into the Contacts application, showing you the list of people.
  • 35. Intent Architecture::Bundle (aka extras) //The bundle is a data structure inside the Intent. //It holds key/value pairs. //Keys are always Strings, and values are always primitives, Serializable or Parcelable. name : Adam Gerber email : gerber@cs.uchicago.edu ret : something... Action Data Scheme Categories ComponentName
  • 36. Serializable versus Parcelable Parcelable is an Interface very much like Serializable only it has been optimized for Android. Unlike Serializeable, all the reflection meta-data has been stripped-out of the parcelized object.
  • 37. Intents Intent messaging is a facility for late run-time binding between components in the same or different applications. Intents are handled by the Android OS. In order for the OS to know about a component, it must be declared in the application manifest file. If a component does not define Intent filters, it can only be called by explicit Intents. A component with filters can receive both explicit and implicit intents. 6/12/12
  • 38. AndroidManifest.xml file Is an inventory of all the components in an application. If the component is not listed there, the Android OS won't know it's there. Not even intra-app component communication will resolve. 6/12/12
  • 40. Categories //Use Categories to further refine your Intent //Most important is CATEGORY_DEFAULT <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
  • 45.
  • 46. Layouts and resources Code: Java (or C if you use NDK) Metafiles: AndroidManifest, project.properties, .gitignore. These all describe the project. Resources “anything in android that is not code or metafiles” Activities have one or more layouts, and all Layouts have a root-ViewGroup. This root-ViewGroup is the container for the Views. R.java (gen directory) is a bridge between your resources and your code. If you want to interact programmatically with a resource, it must have an id.
  • 47.
  • 48. Inspecting layouts and resources You can view both xml and design mode in AS. You can see how it would look on multiple devices || preview all screens, and toggle with remove previews.
  • 49. Layouts and resources res directories can have suffixes, such as layout-land, or drawable-hdpi, values-es, etc. These suffixes allow you to differentiate at RUNTIME depending on the settings, hardware, and configuration of the device. For example, if your device is in landscape mode, it'll try to fetch the layout from layout-land first, then it will try to fetch the layout from layout. Vice versa as well; if it's in portait mode, it'll try for layout-port, then layout. shown in preview mode of resource and rotate device
  • 51.
  • 52.
  • 53.
  • 54. how to copy files from a bc branch to a lb branch Actions || Open in Terminal git checkout c7c7 res/drawable-*/. git checkout c7c7 res/values/str* before a commit you may remove from stage, then: discard: for existing files that you want to roll back remove: for new files that you want to delete
  • 55. ADB (Android Device Bridge) adb kill-server adb start-server adb get-state adb devices Use kill-server / start-server to reboot the adb if your device/emulator is not communicating with your dev-machine.
  • 56. Navigating in Android Studio alt-1 is project view (alt-F1 is show it in project view) alt-2 is favorites (including bookmarks and breakpoints) alt-3 is the search view (cntl-shift-F to find) alt-4 run-console alt-5 is debug alt-6 is android view (ddms, logcat) alt-7 is structure view (see members and methods) alt-9 is changes(VCS) view Look at the margin of your project
  • 57. Get help cntl-shift-A (find anything in Android studio) Searching (on mac, replace cntrl with command) cntl-F (find something in the local file) cntl-shift-F (find something in the project) Go to file in code (on mac, replace cntrl with command) cntl-N (go to files typically in src) cntl-shift-n (go to any file, including res) cntl-E (open recent files) Go to file in project alt-F1
  • 58. Go to definition cntl-B (go directly to the method definition) Javadocs cntl-Q (open the javadocs) Live Templates cntl-J adding your own Live Templates (cntl-shift-A “live template”)
  • 59. Debugging Using the debugger (alt-5) See bookmarks and breakpoints (alt-2) F11 to toggle bookmark Using logcat (alt-6) Using lint and AS analyzer: Analyze || Inspect Code ///TODO this is my todo message