Download presentation
Presentation is loading. Please wait.
Published byMaurice Wilkins Modified over 6 years ago
1
Lecture 3 agenda A tour of Android studio features
Customizing Android Studio (Gerber 16) Debugging Android (Gerber 12) Intents (both explicit and implicit) The Activity Lifecycle ListViews and Adapters 1
2
Navigating Android Studio
2
3
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
4
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 | Cmd-O (go to files typically in src) cntl-shift-n | Cmd-shift-O (go to any file, including res) cntl-E (open recent files) Go to file in project alt-F1
5
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”)
6
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. How to export path using Mac.
7
Debugging Android Studio
7
9
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
10
6/9/12
11
SP scale independent pixels respects the users' settings for font size.
6/9/12
12
Fragments...what good are they?
6/9/12
13
Intents 13
17
From Google: An Intent object is a bundle of information
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)
18
Activated by Intents Activities Services
Broadcast Receivers (aka Receivers) ( ts/intents-filters.html) 18
19
Explicit Intent //Explicit; all you need is the Context and the target class Intent itn = new Intent(this, ResultActivity.class); ResultActivity.class Explicit
20
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 ResultActivity.class Explicit
21
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 ret : something... Action Data Scheme Categories ComponentName Explicit Implicit
22
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); //
23
Explicit Intents: intra-app call by name
Intent itnThird = new Intent(this, ThirdActivity.class); itnThird.putExtra("name", "Adam Gerber"); itnThird.putExtra(" ", startActivity(itnThird);
24
Implicit Intents: inter-app call
Implicit intents are anonymous and loosely-coupled. You request the component like a service of the operating system. Intent itn = new Intent(Intent.ACTION_VIEW, Uri.parse(" startActivity(itn);
25
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: 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: 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.
26
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 ret : something... Action Data Scheme Categories ComponentName ssfdf exp imp
27
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.
28
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
29
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
30
Android OS AndroidManifest.xml I *A A A *A
Activies, Receivers, Services, and Content-Providers all must be declared in the manifest. Intnets are calls to the op-system. It handles all intents, explicit and implicit.
31
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>
32
Lifecycle in Android 32
36
ListViews and Adapters
36
37
Adapters 37
38
AdapterViews 38
39
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.