P. 1
Android Lab

Android Lab

|Views: 397|Likes:
Published by LeoNguyen.com
Android Lab
http://leonguyen.com
Android Lab
http://leonguyen.com

More info:

Categories:Types, Presentations
Published by: LeoNguyen.com on Feb 25, 2013
Copyright:Attribution Non-commercial
List Price: $4.99 Buy Now

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
See more
See less

09/18/2014

$4.99

USD

pdf

text

original

Sections

  • Task 1 - Download JDK
  • Task 2: Open Android SDK Manager
  • Task 3: Create Context Menu XML
  • Task 4: Defining an Context Menu XML
  • Task 5: Add menu
  • Task 6: Execute your program
  • Task 7: Execute your program
  • Task 8: Create UserDA class
  • Task 9: Write a MainActivity program

LeoNguyen.

com

Outline
- Lab 01: An introduction to Android - Lab 02.1: Linear Layout - Lab 02.2: Layout - Lab 02.3: List View Layout - Lab 02.4: Menu - Lab 02.5: Dialog - Lab 02.6: Widget - Lab 03.1: Shares Preferences - Lab 03.2: SQLite - Lab 03.3: Internal and External - Lab 04.1: Intent - Lab 04.2: Content Provider - Lab 04.3: Broadcast Receiver

Outline (cont)
- Lab 05: An introduction to PhoneGap

References
- Developer Android (developer.android.com) - Mobile Tus (mobile.tutsplus.com) - Androidhive (www.androidhive.info) - Code Of A Ninja (www.codeofaninja.com) - Vogella (www.vogella.com/android.html) - Java Papers (www.javapapers.com) - Android-er (android-er.blogspot.com) - Mkyong (http://bit.ly/12XCJOW) - Java2s (www.java2s.com) - Dan Clarke (dan.clarke.name) - My Sample Code (www.mysamplecode.com) - Android Design Patterns (www.androiddesignpatterns.com) - Wagied Davids (w2davids.wordpress.com)

References (cont)
- MyDoople (www.mydoople.com) - Android Dev (http://bit.ly/10IFFRm) - Viralpatel (http://bit.ly/18ICNZd) - Scaloid (blog.scaloid.org) - Android UI (androiduiux.com) - Android Begin (http://bit.ly/11f1Lri) - Android Exp (http://bit.ly/Zm0ktu) - Developer Feed (http://bit.ly/11MY1lR) - Programmer Guru (android.programmerguru.com) - Suvendu (http://bit.ly/10IHKge) - Xamarin (http://bit.ly/15sGkpW) - Marakana (http://bit.ly/13vM0y6) - Grokking Android (www.grokkingandroid.com)

androidpatterns.Android Aspect (www.ly/10R5kUG) .com) .Tech Blog On (http://bit.ly/13cXN5G) .References (cont) .survivingwithandroid.androidaspect.Knowledge of Experience (http://bit.Android Hub 4 You (www.ly/18IFOsh) .blogspot.com) .androidhub4you.ly/11f2Wa5) .New Think Tank (http://bit.com) .Java Code Geeks (http://bit.ly/13vMmF9) .ly/13vNLv7) .Android Education (android-ed.Android App Market (www.com) .Sachin Shelke (http://bit.ly/148e7Wr) .com) .android-app-market.Surviving With Android (www.com) .Android Patterns (www.Android Mobile Develope (http://bit.Tutorial Point (http://bit.

References (cont) .ly/13vOc91) .Clean Code (http://bit.The Android (http://bit.ly/19yBbzX) .Android Tuts (androidituts.Think Android (thinkandroid.Mr Bool (mrbool.ly/Zm2wRS) .ly/15YprUo) .Pavand (bit.ly/12XIJHl) .ly/Zm2Rns) .Android For Beginners (http://bit.commrbool.wordpress.ly/15sWbqS) .Romain Guy (http://bit.com) .com) .Android Guide Tips (http://bit.Traintelco (bit.com) .

Lab 01 An introduction to Android .

Outline .Download and install JDK .Write a Helloworld program (Use ADT) .Download Android Developer Tools (ADT) .Download Android Studio .Write a Helloworld program (Use AS) .

Exercise 1 Download and install JDK .

JDK & JRE .

html .Goto Java download site http://www.Task 1 .Download JDK . com/technetwork/java/javase/downloads/index.oracle.

Task 1 .Download JDK (cont) . choose your operation platform (eg Window X86) and download it .Select Java Platform (JDK).

Run the downloaded installer.Task 2 . By default the JDK and JRE will be installed into directories C:\Program Files\Java .Install JDK . which installs both the JDK (Java Development Kit) and JRE (Java Runtime).

Click the "Start" button > "Control Panel" > "System" > (Vista/7 only) "Advanced system settings" . It helps programmer can compile Java code in CMD shell.Task 3 .Windows Operating System searches the current directory and the directories listed in the PATH environment variable for executable programs invoked from the CMD shell. .Config PATH environment variables .

Task 3 .Config PATH .. (cont) .

Task 4 - Verify the JDK Installation
- Launch a CMD shell > type java –version to check that JDK is properly installed and display its version, and javac to check Path work properly too.

Exercise 2

Download ADT

Task 1: Download ADT
- Go to: http://developer.android.com/sdk/index.html

Task 2: Open Android SDK Manager
- Install Android API

Task 3: Create Android Virtual Device
- Goto Tools > Manage AVDs

Task 3: Create Android Virtual Device (cont) .Choose New. .

.Choose Start.Task 3: Create Android Virtual Device (cont) .

Exercise 3 Write a Helloworld program (Use ADT) .

Task 1: Run Eclipse ADT .Open eclipse.exe .

Task 2: Create Android Application .Go to File > New > Android Application Project .

Task 2: Create Android Application (cont) .

github.Task 2: Create Android Application (cont) .The Main XML Layout: https://gist. com/leonguyen/5351679 .

com/leonguyen/5351695 .java: https://gist.Task 3: Write a MainActivity program .github.Open MainActivity.

Enter code: https://gist.com/leonguyen/5301102 .Task 3: Write a MainActivity program (cont) .github.

Choose "Run As" > "Android Application" .Task 4: Execute your program .

Task 4: Execute your program (cont) .Select and start AVD. .

Choose running Android device. .Task 4: Execute your program (cont) .

.Task 4: Execute your program (cont) .Choose AndroidLab.

Exercise 4 Download AS .

android.html .com/sdk/installing/studio.Task 1: Download AS .Go to: http://developer.

Exercise 5 Write a Helloworld program (Use AS) .

Open Android Studio shortcut.Task 1: Run AS . .

.Select New Project.Task 2: Create Android Application . ..

Input Android application name. .Task 2: Create Android Application (cont) .

.Input Android application icon.Task 2: Create Android Application (cont) .

.Task 2: Create Android Application (cont) .Select Android application activity.

.Input Android application activity name.Task 2: Create Android Application (cont) .

1 Linear Layout .Lab 02.

Linear Layout .Linear Layout .Linear Layout .Message .Quiz .Linear Layout .Register .Linear Layout .Outline .Home .Login .Linear Layout .

Exercise 1 Linear Layout .

A LinearLayout respects margins between children and the gravity (right. . and a horizontal list will only be one row high (the height of the tallest child. no matter how wide they are. . so a vertical list will only have one child per row.Linear Layout . or left alignment) of each child.A layout is a view group that aligns all children in a single direction. vertically or horizontally. plus padding).All children of a LinearLayout are stacked one after the other. center.

Then set the android:layout_weight of each view to "1".Layout weight . . set the android:layout_height of each view to "0dp" (for a vertical layout) or the android: layout_width of each view to "0dp" (for a horizontal layout).To create a linear layout in which each child uses the same amount of space on the screen.

Task 1: Create XML Layout . .Right click on the res/layout folder.

com/leonguyen/5308746 .github.Enter code: https://gist.Task 2: Defining an XML Layout .

Choose "Run As" > "Android Application" .Task 3: Execute your program .

Message .Exercise 2 Linear Layout .

com/leonguyen/5325407 .github.Enter code: https://gist.Task 1: Defining an XML Layout .

Task 2: Execute your program .Choose "Run As" > "Android Application" .

Quiz .Exercise 3 Linear Layout .

github.Task 1: Defining an XML Layout .Enter code: https://gist.com/leonguyen/5325424 .

Choose "Run As" > "Android Application" .Task 2: Execute your program .

Login .Exercise 4 Linear Layout .

Enter code: https://gist.Task 1: Defining an XML Layout .github.com/leonguyen/5329665 .

Task 2: Execute your program .Choose "Run As" > "Android Application" .

Register .Exercise 5 Linear Layout .

com/leonguyen/5329865 .github.Task 1: Defining an XML Layout .Enter code: https://gist.

Choose "Run As" > "Android Application" .Task 2: Execute your program .

Home .Exercise 6 Linear Layout .

.Right click on the res folder.Task 1: Create XML Drawable .

github.Enter code: https://gist.com/leonguyen/5516102 .Task 2: Defining an XML Drawable .

Enter code: https://gist.github.com/leonguyen/5515898 .Task 3: Defining an XML Layout .

Task 4: Execute your program .Choose "Run As" > "Android Application" .

Lab 02.2 Layout .

Relative Layout .Relative Layout .Scroll View .Reminder .Work .Table Layout .Table Layout .Relative Layout .Outline .Weather .

Exercise 1 Relative Layout .

A layout is a view group that displays child views in relative positions. .Relative Layout .

These are just a few examples. All layout attributes are documented at RelativeLayout. centers this child vertically within its parent.Positioning Views . android:layout_centerVertical If "true".LayoutParams.Some of the many layout properties available to views in a RelativeLayout include: android:layout_alignParentTop If "true". . makes the top edge of this view match the top edge of the parent. android:layout_below Positions the top edge of this view below the view specified with a resource ID. android:layout_toRightOf Positions the left edge of this view to the right of the view specified with a resource ID.

Task 1: Create XML Layout .Right click on the res/layout folder. .

Enter code: https://gist.com/leonguyen/5309283 .github.Task 2: Defining an XML Layout .

Task 3: Execute your program .Choose "Run As" > "Android Application" .

Reminder .Exercise 2 Relative Layout .

Task 1: Defining an XML Layout .com/leonguyen/5325475 .Enter code: https://gist.github.

Choose "Run As" > "Android Application" .Task 2: Execute your program .

Work .Exercise 3 Relative Layout .

Enter code: https://gist.com/leonguyen/5329563 .Task 1: Defining an XML Layout .github.

Choose "Run As" > "Android Application" .Task 2: Execute your program .

Exercise 4 Table Layout .

you can have other children. which will be explained below).Table Layout . each defining a row (actually. or cells. as they can in HTML. A TableLayout consists of a number of TableRow objects. each cell can hold one View object.A layout that arranges its children into rows and columns. Each row has zero or more cells. . TableLayout containers do not display border lines for their rows. A table can leave cells empty. columns. Cells can span columns. The table has as many columns as the row with the most cells.

Task 1: Create XML Layout .Right click on the res/layout folder. .

Enter code: https://gist.Task 2: Defining an XML Layout .com/leonguyen/5325531 .github.

Task 3: Execute your program .Choose "Run As" > "Android Application" .

Weather .Exercise 5 Table Layout .

com/leonguyen/5325537 .Task 1: Defining an XML Layout .Enter code: https://gist.github.

Choose "Run As" > "Android Application" .Task 2: Execute your program .

Exercise 6 Scroll View .

Right click on the res/layout folder. .Task 1: Create XML Layout .

com/leonguyen/5331192 .Task 1: Defining an XML Layout .github.Enter code: https://gist.

Task 2: Execute your program .Choose "Run As" > "Android Application" .

3 List View Layout .Lab 02.

List View with Thread .List View with Custom Adapter .List View with Activity and Custom Main Layout .List View with Activity .Outline .List View with Custom ArrayList .List View with Custom Layout .List View with Context Menu .List View .

Exercise 1 List View .

List View
- A view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

ArrayAdapter
- Use this adapter when your data source is an array. By default, ArrayAdapter creates a view for each array item by calling toString() on each item and placing the contents in a TextView.

Task 1: Create ListView Activity
- Enter code: https://gist.github.com/leonguyen/5335106

Task 2: Execute your program
- Choose "Run As" > "Android Application"

Exercise 2

List View with Custom Layout

Task 1: Create XML Layout . .Right click on the res/layout folder.

com/leonguyen/5335460 .Task 2: Defining an XML Layout .github.Enter code: https://gist.

Enter code: https://gist.github.Task 3: Create ListView Activity .com/leonguyen/5335493 .

Choose "Run As" > "Android Application" .Task 4: Execute your program .

Exercise 3 List View with Context Menu .

github.Task 1: Create ListView Activity .Enter code: https://gist.com/leonguyen/5335493 .

.Enter code.Task 2: Register ListView for ContextMenu .

Task 3: Create Context Menu XML . .Right click on the res/menu folder.

com/leonguyen/5345210 .Enter code: https://gist.github.Task 4: Defining an Context Menu XML .

.Right click on editor.Task 3: Create onCreateContextMenu() .

.Task 4: Create onContextItemSelected() .Right click on editor.

github.Task 5: Add menu .com/leonguyen/5344253 .Enter code: https://gist.

Task 6: Execute your program .Choose "Run As" > "Android Application" .

Exercise 3 List View with Custom Adapter .

Task 1: Defining an XML Layout .Enter code: https://gist.com/leonguyen/5335460 .github.

Task 2: Create Custom Adapter class .com/leonguyen/5450429 .Enter code: https://gist.github.

com/leonguyen/5450482 .Enter code: https://gist.Task 3: Create List View Activity .github.

Choose "Run As" > "Android Application" .Task 4: Execute your program .

Exercise 4 List View with Custom ArrayList .

Enter code: https://gist.github.Task 1: Defining an XML Layout .com/leonguyen/5632592 .

github.Task 2: Create Custom Adapter class .com/leonguyen/5632608 .Enter code: https://gist.

Enter code: https://gist.github.com/leonguyen/5632651 .Task 3: Create List View Activity .

Task 4: Execute your program .Choose "Run As" > "Android Application" .

Using a CursorLoader is the standard way to query a Cursor as an asynchronous task in order to avoid blocking your app's main thread with the query.Loader . which is where you update your Adapter with the new Cursor and the list view then displays the results. . the LoaderCallbacks receives a callback to onLoadFinished().When the CursorLoader receives the Cursor result. .

SimpleCursorAdapter . When using SimpleCursorAdapter.Use this adapter when your data comes from a Cursor. you must specify a layout to use for each row in the Cursor and which columns in the Cursor should be inserted into which views of the layout. .

4 Menu .Lab 02.

Option Menu .Outline .

Exercise 1 Option Menu .

Right click on the res/menu folder.Task 1: Create Dialog XML Layout . .

com/leonguyen/5353541 .Task 3: Defining an XML Layout .github.Enter code: https://gist.

Task 3: Create onCreateContextMenu() . .Right click on editor.

github.com/leonguyen/5353562 .Task 4: Add Option Menu .Enter code: https://gist.

Task 4: Execute your program .Choose "Run As" > "Android Application" .

Lab 02.5 Dialog .

Dialog with Custom Layout .Outline .Alert Dialog .

Exercise 1 Alert Dialog .

Edit file res/layout/activity_main.xml: https://gist. com/leonguyen/5351375 .github.Task 1: Create Button in Main Layout .

Enter code: https://gist.github.Task 2: Create Alert Dialog program .com/leonguyen/5353961 .

Task 3: Execute your program .Choose "Run As" > "Android Application" .

Exercise 2 Dialog with Custom Layout .

Edit file res/layout/activity_main.Task 1: Create Button in Main Layout .github. com/leonguyen/5351375 .xml: https://gist.

.Right click on the res/layout folder.Task 2: Create Dialog XML Layout .

Task 3: Defining an XML Layout .github.Enter code: https://gist.com/leonguyen/5351420 .

Task 3: Create Custom Dialog program .com/leonguyen/5351822 .Enter code: https://gist.github.

Task 4: Execute your program .Choose "Run As" > "Android Application" .

Lab 02.6 Widget .

Outline .Widget .

defined in XML.To create an App Widget.Widget . update frequency. based on broadcast events. you need the following: + AppWidgetProviderInfo object Describes the metadata for an App Widget. + AppWidgetProvider class implementation Defines the basic methods that allow you to programmatically interface with the App Widget. .App Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic updates. . + View layout Defines the initial layout for the App Widget. such as the App Widget's layout. and the AppWidgetProvider class.

Exercise 1 Widget .

Enter code: https://gist.Task 1: Defining an Widget Drawable .github.com/leonguyen/5667758 .

github.Enter code: https://gist.com/leonguyen/5667769 .Task 2: Defining an Widget XML Layout .

Task 3: Create AppWidgetProviderInfo Metadata .Right click on the res/xml folder. .

com/leonguyen/5667832 .Task 4: Defining AppWidgetProviderInfo Metadata .github.Enter code: https://gist.

Enter code: https://gist.Task 5: Create Widget Provider program .github.com/leonguyen/5667853 .

com/leonguyen/5667862 .Enter code: https://gist.Task 6: Declaring an App Widget in the Manifest .github.

Choose "Run As" > "Android Application": http://youtu.be/LTsvhrDoDg .Task 7: Execute your program .

Lab 03.1 Shared Preferences .

Preference Activity .Shared Preferences .Shared Preferences .Outline .

+ getPreferences() . . you don't supply a name.The SharedPreferences class provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans.Use this if you need multiple preferences files identified by name. ints. longs. floats. + getSharedPreferences() .Shared Preferences . Because this will be the only preferences file for your Activity.Use this if you need only one preferences file for your Activity. and strings. This data will persist across user sessions (even if your application is killed). which you specify with the first parameter.

Exercise 1 Shared References .

github.xml: https://gist.Task 1: Defining Main XML Layout .Edit file res/layout/activity_main. com/leonguyen/5402754 .

Enter code: https://gist.com/leonguyen/5402780 .github.Task 2: Write a MainActivity program .

Choose "Run As" > "Android Application": http://youtu. be/Gj2VkO8zxaM .Task 3: Execute your program .

Reference Activity .Exercise 2 Shared References .

Task 1: Defining Main XML Menu .Edit file res/menu/main.github. com/leonguyen/5409423 .xml: https://gist.

.Task 2: Create Array XML Value .Right click on the res/values folder.

Task 3: Defining Array XML Value
- Edit file res/xml/arrays.xml: https://gist.github.com/leonguyen/5409973

Task 4: Create Preference XML
- Right click on the res/xml folder.

Task 5: Defining Preference XML
- Edit file res/xml/preferences.xml: https://gist.github.com/leonguyen/5409597

Task 6: Create PreferenceActivity
- Enter code: https://gist.github.com/leonguyen/5409613

Task 7: Defining Android Manifest
- Enter code: https://gist.github.com/leonguyen/5409836

com/leonguyen/5410070 .Enter code: https://gist.Task 8: Write MainActivity program .github.

Choose "Run As" > "Android Application": http://youtu. be/CDyIaC3woZU .Task 9: Execute your program .

Task 9: Execute your program (cont) .

Task 9: Execute your program (cont) .

Lab 03.2 SQLite .

SQLite .SQLite with Multiple Tables CRUD .Outline .SQLite with Design Pattern .SQLite with Multiple Tables .SQLite with CRUD .

Exercise 1 SQLite .

Enter code: https://gist.com/leonguyen/5425508 .Task 1: Create Database class .github.

Enter code: https://gist.github.com/leonguyen/5425557 .Task 2: Write a MainActivity program .

Task 3: Execute your program .Choose "Run As" > "Android Application" .

Exercise 2 SQLite with Multiple Tables .

com/leonguyen/5425418 .github.Enter code: https://gist.Task 1: Create Entity class .

Enter code: https://gist.github.Task 2: Create Database Object class .com/leonguyen/5524350 .

Task 3: Create Database Helper class .Enter code: https://gist.github.com/leonguyen/5524390 .

com/leonguyen/5524451 .github.Task 4: Write a MainActivity program .Enter code: https://gist.

Task 5: Execute your program .Choose "Run As" > "Android Application" .

Exercise 3 SQLite with CRUD .

Task 1: Create User Entity class .github.com/leonguyen/5425418 .Enter code: https://gist.

github.com/leonguyen/5425683 .Task 2: Create UserDA class with CRUD .Enter code: https://gist.

Enter code: https://gist.com/leonguyen/5425704 .Task 3: Write a MainActivity program .github.

Task 4: Execute your program .Choose "Run As" > "Android Application" .

Exercise 4 SQLite with Multiple Tables CRUD .

com/leonguyen/5425418 .Task 1: Create User Entity class .Enter code: https://gist.github.

github.Enter code: https://gist.Task 2: Create UserDA class with CRUD .com/leonguyen/5524722 .

Task 3: Create Database Helper class .com/leonguyen/5525519 .Enter code: https://gist.github.

Enter code: https://gist.com/leonguyen/5525541 .Task 4: Write a MainActivity program .github.

Task 5: Execute your program .Choose "Run As" > "Android Application" .

Exercise 5 SQLite with Design Pattern .

UML Diagram .

com/leonguyen/5683910 .Task 1: Create Person Abstract class .github.Enter code: https://gist.

Task 2: Create User Entity class .Enter code: https://gist.github.com/leonguyen/5683921 .

github.Enter code: https://gist.Task 3: Create DB Config Enum .com/leonguyen/5683976 .

Task 4: Create Table Helper class .com/leonguyen/5684167 .Enter code: https://gist.github.

com/leonguyen/5684181 .github.Task 5: Create User Table class .Enter code: https://gist.

Task 6: Create Data Manipulation Object class .github.com/leonguyen/5684403 .Enter code: https://gist.

Enter code: https://gist.Task 7: Create Database class .github.com/leonguyen/5684414 .

github.Enter code: https://gist.com/leonguyen/5692560 .Task 8: Create UserDA class .

com/leonguyen/5692570 .github.Enter code: https://gist.Task 9: Write a MainActivity program .

External .Lab 03.3 Internal.

External with File .External with SQLite .Outline .Internal.

these files are removed.External storage such as SD card can also store application data.Internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application. .Storage . there's no security enforced upon files you save to the external storage. . All applications can read and write files placed on the external storage and the user can remove them.

External with File .Exercise 1 Internal.

github.Enter code: https://gist.Task 1: Defining Main XML Layout .com/leonguyen/5452672 .

github.Enter code: https://gist.com/leonguyen/5452728 .Task 2: Register Storage permission .

github.Task 3: Write a MainActivity program .Enter code: https://gist.com/leonguyen/5452749 .

Choose "Run As" > "Android Application": http://youtu.Task 4: Execute your program . be/6BE2BEnoZKM .

Task 4: Execute your program (cont) .

Exercise 2 External with SQLite .

github.com/leonguyen/5465834 .Enter code: https://gist.Task 1: Create Database class .

Enter code: https://gist.com/leonguyen/5425557 .Task 3: Write a MainActivity program .github.

Task 3: Execute your program .Choose "Run As" > "Android Application" .

1 Intent .Lab 04.

Intent .Outline .Intent Explicit .

from hardware state changes (e. running around the inside of the device. For example an Activity can send an Intents to the Android system which starts another Activity.g. your activity was launched from the device’s main menu).an SD card was inserted). or to let you know when specific situations arise (e.. .g. to incoming data (e.Intents are system messages.Intent .g. and broadcast receivers — are activated through messages..to application events (e. services. notifying applications of various events.g. an SMS message arrived).Not only can you respond to intents. but you can create your own.Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system. .. to launch other activities. . raise such-and-so intent when the user click this button).Three of the core components of an application — activities.. . called intents.

. Implicit intents are often used to activate components in other applications. Since component names would generally not be known to developers of other applications.Implicit intents do not name a target (the field for the component name is blank).Explicit intents designate the target component by its name (the component name field. .Explicit and Implicit . mentioned earlier. has a value set). explicit intents are typically used for application-internal messages.

Exercise 1 Intent .

Enter code: https://gist.Task 1: Defining Main XML Layout .github.com/leonguyen/5473266 .

com/leonguyen/5473386 .Enter code: https://gist.Task 2: Write a MainActivity program .github.

Task 3: Execute your program . be/tJaNGzoGUG4 .Choose "Run As" > "Android Application": http://youtu.

Exercise 2 Intent Explicit .

github.Task 1: Defining Main XML Layout .Enter code: https://gist.com/leonguyen/5486271 .

Task 2: Defining Second XML Layout .Enter code: https://gist.github.com/leonguyen/5486303 .

github.com/leonguyen/5486377 .Task 3: Write a MainActivity program .Enter code: https://gist.

com/leonguyen/5486384 .Enter code: https://gist.Task 4: Write a SecondActivity program .github.

Choose "Run As" > "Android Application": http://youtu.be/7ewZXibMFy4 .Task 5: Execute your program .

Lab 04.2 Content Provider .

Content Provider Custom . Call Log Picker .Content Provider with Settings .Content Provider .Content Provider with Contact.Outline .

Insert.ContentResolver is a static proxy that communicates with a ContentProvider to access its data. . either from within the same application or from another application. .Content Provider . Update and Delete.ContentProvider manage access to a structured set of data. The main methods are Query.

. including people.UserDictionary – contents of the user-defined dictionary used for predictive text input. . artists. .Android offers access to a wide range of system and user data using ContentProviders. .CallLog – recent calls made or received with the device. photos & groups.Contacts – detailed information from the user’s contact list. . . phones. . .Settings – system-wide device settings and preferences. images (including thumbnails) & video.Built-In Provider . playlists).Browser – bookmarks and browser history (requires permission READ_HISTORY_BOOKMARKS and/or WRITE_HISTORY_BOOKMARKS).Voicemail – history of voicemail messages. genres.MediaStore – contents of the user’s device: audio (albums.

Exercise 1 Content Provider .

Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5487428

Task 2: Register Contact permission
- Enter code: https://gist.github.com/leonguyen/5487519

Task 3: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5487527

Task 4: Execute your program
- Choose "Run As" > "Android Application": http://youtu. be/21AQ5NFtv-w

Exercise 2

Content Provider with Contact, Call Log Picker

com/leonguyen/5519593 .Task 1: Defining Main XML Layout .Enter code: https://gist.github.

github.Task 2: Register Contact permission .com/leonguyen/5487519 .Enter code: https://gist.

com/leonguyen/5519616 .Enter code: https://gist.Task 3: Write a MainActivity program .github.

Task 4: Execute your program . be/CzhJTPPx6oI .Choose "Run As" > "Android Application": http://youtu.

Exercise 3 Content Provider with Settings .

Task 1: Defining Main XML Layout .github.Enter code: https://gist.com/leonguyen/5489929 .

com/leonguyen/5489952 .Task 2: Defining Item XML .Enter code: https://gist.github.

com/leonguyen/5487519 .Enter code: https://gist.github.Task 3: Set Contact permission .

Task 4: Write a MainActivity program .com/leonguyen/5489972 .github.Enter code: https://gist.

Task 5: Execute your program .Choose "Run As" > "Android Application": http://youtu.be/q--akeZkw8 .

3 Broadcast Receiver .Lab 04.

Broadcast Receiver with Custom Intent .Outline .Broadcast Receiver .Broadcast Receiver with Incoming SMS .Broadcast Receiver with Incoming Phone Call .

Broadcast Receiver . These messages are sometime called events or intents. .Broadcast Receiver simply respond to broadcast messages from other applications or from the system itself.

Show activity for reporting a bug. The date has changed.intent.intent.action.action.action. Perform a call to someone specified by the data.intent.intent.action.CALL android.action.intent.intent. Indicates the battery is now okay after being low. This is broadcast once. The user pressed the "call" button to go to the dialer or other appropriate UI for placing a call.action.action.intent.REBOOT Description Sticky broadcast containing the charging state. and other information about the battery. level.BATTERY_CHANGED android.System Events Event Constant android.intent.BATTERY_OKAY android. Indicates low battery condition on the device. .BOOT_COMPLETED android. Have the device reboot. after the system has finished booting.BATTERY_LOW android.action.DATE_CHANGED android.action.intent.BUG_REPORT android.CALL_BUTTON android.

Exercise 1 Broadcast Receiver .

com/leonguyen/5500078 .Task 1: Create Broadcast Receiver class .Enter code: https://gist.github.

github.Enter code: https://gist.com/leonguyen/5500092 .Task 2: Register Broadcast Receiver permission .

Task 3: Execute your program .Choose "Run As" > "Android Application": http://youtu. be/CuF9IakbEl0 .

Exercise 2 Broadcast Receiver with Custom Intent .

Task 1: Defining Main XML Layout .com/leonguyen/5500996 .github.Enter code: https://gist.

Task 2: Create Broadcast Receiver class .com/leonguyen/5501217 .Enter code: https://gist.github.

Enter code: https://gist.Task 3: Register Broadcast Receiver permission .github.com/leonguyen/5501232 .

github.com/leonguyen/5501294 .Enter code: https://gist.Task 4: Write a MainActivity program .

be/SyLzgtC0Rgw .Choose "Run As" > "Android Application": http://youtu.Task 5: Execute your program .

Exercise 3 Broadcast Receiver with Incoming SMS .

Task 1: Create Broadcast Receiver class .com/leonguyen/5506820 .Enter code: https://gist.github.

github.Enter code: https://gist.com/leonguyen/5506839 .Task 2: Register Broadcast Receiver permission .

Choose "Run As" > "Android Application": http://youtu.be/CEKaJUV5ZM .Task 3: Execute your program .

Exercise 4 Broadcast Receiver with Incoming Phone Call .

com/leonguyen/5506917 .github.Enter code: https://gist.Task 1: Create Broadcast Receiver class .

Enter code: https://gist.github.Task 2: Register Broadcast Receiver permission .com/leonguyen/5506953 .

Choose "Run As" > "Android Application": http://youtu.be/Rj1I04fsQQk .Task 3: Execute your program .

Lab 05 An introduction to PhoneGap .

ly/H0NyLg) .ly/1bDCxsZ) .Getting started with PhoneGap in Eclipse for Android (adobe.References .ly/H0NDOW) .PhoneGap From Scratch (bit.Build a Feed Reader (bit.

Configure the project .Write a Hellworld program .Outline .Download and install .

Exercise 1 Download and install .

Overview .

Goto download site http://phonegap.Task 1 .Download .com/install/ .

Exercise 2 Configure the project .

Task 1: Create ‘www’ folder . .Create the ‘www’ folder under assets folder.

Copy ‘cordova.js’ and ‘cordova.js’ to Android project.Task 2: Copy PhoneGap libraries . .

Exercise 3 Write a Helloworld program .

html .com/leonguyen/7036244 .html’ under ‘assets/www’ folder then enter code: gist.Create the ‘index.github.Task 1: Create index.

Task 2: Add to Build Path .jar’ then select Add to Build Path .Right click on ‘cordova.

github.Enter code: gist.Task 3: Update Activity class .com/leonguyen/7036322 .

Task 4: Configure the project metadata .github.com/leonguyen/7036370 .Enter code: gist.

Task 4: Configure the project metadata (2) .

Choose "Run As" > "Android Application". .Task 5: Run .

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->