SlideShare ist ein Scribd-Unternehmen logo
1 von 296
Downloaden Sie, um offline zu lesen
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)
References (cont)
- Android Mobile Develope (http://bit.ly/148e7Wr)
- Android Patterns (www.androidpatterns.com)
- Tutorial Point (http://bit.ly/13vMmF9)
- Android Education (android-ed.blogspot.com)
- Tech Blog On (http://bit.ly/11f2Wa5)
- Android App Market (www.android-app-market.com)
- Java Code Geeks (http://bit.ly/18IFOsh)
- New Think Tank (http://bit.ly/13cXN5G)
- Android Aspect (www.androidaspect.com)
- Android Hub 4 You (www.androidhub4you.com)
- Surviving With Android (www.survivingwithandroid.com)
- Sachin Shelke (http://bit.ly/10R5kUG)
- Knowledge of Experience (http://bit.ly/13vNLv7)
References (cont)
- Android For Beginners (http://bit.ly/Zm2wRS)
- Clean Code (http://bit.ly/19yBbzX)
- Think Android (thinkandroid.wordpress.com)
- Romain Guy (http://bit.ly/13vOc91)
- Mr Bool (mrbool.commrbool.com)
- Android Guide Tips (http://bit.ly/Zm2Rns)
- The Android (http://bit.ly/12XIJHl)
- Android Tuts (androidituts.com)
- Traintelco (bit.ly/15YprUo)
- Pavand (bit.ly/15sWbqS)
Lab 01
An introduction to Android
Outline
- Download and install JDK
- Download Android Developer Tools (ADT)
- Write a Helloworld program (Use ADT)
- Download Android Studio
- Write a Helloworld program (Use AS)
Exercise 1

Download and install JDK
JDK & JRE
Task 1 - Download JDK
- Goto Java download site http://www.oracle.
com/technetwork/java/javase/downloads/index.html
Task 1 - Download JDK (cont)
- Select Java Platform (JDK), choose your operation platform (eg
Window X86) and download it
Task 2 - Install JDK
- Run the downloaded installer, which installs both the JDK (Java
Development Kit) and JRE (Java Runtime). By default the JDK and
JRE will be installed into directories C:Program FilesJava
Task 3 - Config PATH environment variables
- Windows Operating System searches the current directory and the
directories listed in the PATH environment variable for executable
programs invoked from the CMD shell. It helps programmer can
compile Java code in CMD shell.
- Click the "Start" button > "Control Panel" > "System" > (Vista/7 only)
"Advanced system settings"
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.
Task 3: Create Android Virtual Device (cont)
- Choose Start.
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)
Task 2: Create Android Application (cont)
- The Main XML Layout: https://gist.github.
com/leonguyen/5351679
Task 3: Write a MainActivity program
- Open MainActivity.java: https://gist.github.
com/leonguyen/5351695
Task 3: Write a MainActivity program (cont)
- Enter code: https://gist.github.com/leonguyen/5301102
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Task 4: Execute your program (cont)
- Select and start AVD.
Task 4: Execute your program (cont)
- Choose running Android device.
Task 4: Execute your program (cont)
- Choose AndroidLab.
Exercise 4

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

Write a Helloworld program (Use AS)
Task 1: Run AS
- Open Android Studio shortcut.
Task 2: Create Android Application
- Select New Project...
Task 2: Create Android Application (cont)
- Input Android application name.
Task 2: Create Android Application (cont)
- Input Android application icon.
Task 2: Create Android Application (cont)
- Select Android application activity.
Task 2: Create Android Application (cont)
- Input Android application activity name.
Lab 02.1
Linear Layout
Outline
- Linear Layout
- Linear Layout - Message
- Linear Layout - Quiz
- Linear Layout - Login
- Linear Layout - Register
- Linear Layout - Home
Exercise 1

Linear Layout
Linear Layout
- A layout is a view group that aligns all children in a single
direction, vertically or horizontally.
- All children of a LinearLayout are stacked one after the other,
so a vertical list will only have one child per row, no matter how
wide they are, and a horizontal list will only be one row high (the
height of the tallest child, plus padding). A LinearLayout respects
margins between children and the gravity (right, center, or left
alignment) of each child.
Layout weight
- To create a linear layout in which each child uses the same
amount of space on the screen, 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). Then
set the android:layout_weight of each view to "1".
Task 1: Create XML Layout
- Right click on the res/layout folder.
Task 2: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5308746
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Exercise 2

Linear Layout - Message
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5325407
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 3

Linear Layout - Quiz
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5325424
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 4

Linear Layout - Login
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5329665
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 5

Linear Layout - Register
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5329865
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 6

Linear Layout - Home
Task 1: Create XML Drawable
- Right click on the res folder.
Task 2: Defining an XML Drawable
- Enter code: https://gist.github.com/leonguyen/5516102
Task 3: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5515898
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Lab 02.2
Layout
Outline
- Relative Layout
- Relative Layout - Reminder
- Relative Layout - Work
- Table Layout
- Table Layout - Weather
- Scroll View
Exercise 1

Relative Layout
Relative Layout
- A layout is a view group that displays child views in relative
positions.
Positioning Views
- 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_centerVertical
If "true", centers this child vertically within its 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.
These are just a few examples. All layout attributes are documented at
RelativeLayout.LayoutParams.
Task 1: Create XML Layout
- Right click on the res/layout folder.
Task 2: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5309283
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Exercise 2

Relative Layout - Reminder
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5325475
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 3

Relative Layout - Work
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5329563
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 4

Table Layout
Table Layout
- A layout that arranges its children into rows and columns. A TableLayout
consists of a number of TableRow objects, each defining a row (actually, you
can have other children, which will be explained below). TableLayout
containers do not display border lines for their rows, columns, or cells. Each
row has zero or more cells; each cell can hold one View object. The table has
as many columns as the row with the most cells. A table can leave cells empty.
Cells can span columns, as they can in HTML.
Task 1: Create XML Layout
- Right click on the res/layout folder.
Task 2: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5325531
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Exercise 5

Table Layout - Weather
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5325537
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Exercise 6

Scroll View
Task 1: Create XML Layout
- Right click on the res/layout folder.
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5331192
Task 2: Execute your program
- Choose "Run As" > "Android Application"
Lab 02.3
List View Layout
Outline
- List View
- List View with Custom Layout
- List View with Context Menu
- List View with Custom Adapter
- List View with Custom ArrayList
- List View with Activity
- List View with Activity and Custom Main Layout
- List View with Thread
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.
Task 2: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5335460
Task 3: Create ListView Activity
- Enter code: https://gist.github.com/leonguyen/5335493
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Exercise 3

List View with Context Menu
Task 1: Create ListView Activity
- Enter code: https://gist.github.com/leonguyen/5335493
Task 2: Register ListView for ContextMenu
- Enter code.
Task 3: Create Context Menu XML
- Right click on the res/menu folder.
Task 4: Defining an Context Menu XML
- Enter code: https://gist.github.com/leonguyen/5345210
Task 3: Create onCreateContextMenu()
- Right click on editor.
Task 4: Create onContextItemSelected()
- Right click on editor.
Task 5: Add menu
- Enter code: https://gist.github.com/leonguyen/5344253
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.github.com/leonguyen/5335460
Task 2: Create Custom Adapter class
- Enter code: https://gist.github.com/leonguyen/5450429
Task 3: Create List View Activity
- Enter code: https://gist.github.com/leonguyen/5450482
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Exercise 4

List View with Custom ArrayList
Task 1: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5632592
Task 2: Create Custom Adapter class
- Enter code: https://gist.github.com/leonguyen/5632608
Task 3: Create List View Activity
- Enter code: https://gist.github.com/leonguyen/5632651
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Loader
- 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.
- When the CursorLoader receives the Cursor result, the
LoaderCallbacks receives a callback to onLoadFinished(), which
is where you update your Adapter with the new Cursor and the
list view then displays the results.
SimpleCursorAdapter
- Use this adapter when your data comes from a Cursor. When
using SimpleCursorAdapter, 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.
Lab 02.4
Menu
Outline
- Option Menu
Exercise 1

Option Menu
Task 1: Create Dialog XML Layout
- Right click on the res/menu folder.
Task 3: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5353541
Task 3: Create onCreateContextMenu()
- Right click on editor.
Task 4: Add Option Menu
- Enter code: https://gist.github.com/leonguyen/5353562
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Lab 02.5
Dialog
Outline
- Alert Dialog
- Dialog with Custom Layout
Exercise 1

Alert Dialog
Task 1: Create Button in Main Layout
- Edit file res/layout/activity_main.xml: https://gist.github.
com/leonguyen/5351375
Task 2: Create Alert Dialog program
- Enter code: https://gist.github.com/leonguyen/5353961
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Exercise 2

Dialog with Custom Layout
Task 1: Create Button in Main Layout
- Edit file res/layout/activity_main.xml: https://gist.github.
com/leonguyen/5351375
Task 2: Create Dialog XML Layout
- Right click on the res/layout folder.
Task 3: Defining an XML Layout
- Enter code: https://gist.github.com/leonguyen/5351420
Task 3: Create Custom Dialog program
- Enter code: https://gist.github.com/leonguyen/5351822
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Lab 02.6
Widget
Outline
- Widget
Widget
- App Widgets are miniature application views that can be
embedded in other applications (such as the Home screen) and
receive periodic updates.
- To create an App Widget, you need the following:
+ AppWidgetProviderInfo object
Describes the metadata for an App Widget, such as the App
Widget's layout, update frequency, and the AppWidgetProvider
class.
+ AppWidgetProvider class implementation
Defines the basic methods that allow you to programmatically
interface with the App Widget, based on broadcast events.
+ View layout
Defines the initial layout for the App Widget, defined in XML.
Exercise 1

Widget
Task 1: Defining an Widget Drawable
- Enter code: https://gist.github.com/leonguyen/5667758
Task 2: Defining an Widget XML Layout
- Enter code: https://gist.github.com/leonguyen/5667769
Task 3: Create AppWidgetProviderInfo Metadata
- Right click on the res/xml folder.
Task 4: Defining AppWidgetProviderInfo Metadata
- Enter code: https://gist.github.com/leonguyen/5667832
Task 5: Create Widget Provider program
- Enter code: https://gist.github.com/leonguyen/5667853
Task 6: Declaring an App Widget in the Manifest
- Enter code: https://gist.github.com/leonguyen/5667862
Task 7: Execute your program
- Choose "Run As" > "Android Application": http://youtu.be/LTsvhrDoDg
Lab 03.1
Shared Preferences
Outline
- Shared Preferences
- Shared Preferences - Preference Activity
Shared Preferences
- 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, floats, ints, longs, and strings. This
data will persist across user sessions (even if your application is
killed).
+ getSharedPreferences() - Use this if you need multiple
preferences files identified by name, which you specify with the
first parameter.
+ getPreferences() - Use this if you need only one preferences
file for your Activity. Because this will be the only preferences file
for your Activity, you don't supply a name.
Exercise 1

Shared References
Task 1: Defining Main XML Layout
- Edit file res/layout/activity_main.xml: https://gist.github.
com/leonguyen/5402754
Task 2: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5402780
Task 3: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/Gj2VkO8zxaM
Exercise 2

Shared References - Reference
Activity
Task 1: Defining Main XML Menu
- Edit file res/menu/main.xml: https://gist.github.
com/leonguyen/5409423
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
Task 8: Write MainActivity program
- Enter code: https://gist.github.com/leonguyen/5410070
Task 9: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/CDyIaC3woZU
Task 9: Execute your program (cont)
Task 9: Execute your program (cont)
Lab 03.2
SQLite
Outline
- SQLite
- SQLite with Multiple Tables
- SQLite with CRUD
- SQLite with Multiple Tables CRUD
- SQLite with Design Pattern
Exercise 1

SQLite
Task 1: Create Database class
- Enter code: https://gist.github.com/leonguyen/5425508
Task 2: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5425557
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Exercise 2

SQLite with Multiple Tables
Task 1: Create Entity class
- Enter code: https://gist.github.com/leonguyen/5425418
Task 2: Create Database Object class
- Enter code: https://gist.github.com/leonguyen/5524350
Task 3: Create Database Helper class
- Enter code: https://gist.github.com/leonguyen/5524390
Task 4: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5524451
Task 5: Execute your program
- Choose "Run As" > "Android Application"
Exercise 3

SQLite with CRUD
Task 1: Create User Entity class
- Enter code: https://gist.github.com/leonguyen/5425418
Task 2: Create UserDA class with CRUD
- Enter code: https://gist.github.com/leonguyen/5425683
Task 3: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5425704
Task 4: Execute your program
- Choose "Run As" > "Android Application"
Exercise 4

SQLite with Multiple Tables CRUD
Task 1: Create User Entity class
- Enter code: https://gist.github.com/leonguyen/5425418
Task 2: Create UserDA class with CRUD
- Enter code: https://gist.github.com/leonguyen/5524722
Task 3: Create Database Helper class
- Enter code: https://gist.github.com/leonguyen/5525519
Task 4: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5525541
Task 5: Execute your program
- Choose "Run As" > "Android Application"
Exercise 5

SQLite with Design Pattern
UML Diagram
Task 1: Create Person Abstract class
- Enter code: https://gist.github.com/leonguyen/5683910
Task 2: Create User Entity class
- Enter code: https://gist.github.com/leonguyen/5683921
Task 3: Create DB Config Enum
- Enter code: https://gist.github.com/leonguyen/5683976
Task 4: Create Table Helper class
- Enter code: https://gist.github.com/leonguyen/5684167
Task 5: Create User Table class
- Enter code: https://gist.github.com/leonguyen/5684181
Task 6: Create Data Manipulation Object class
- Enter code: https://gist.github.com/leonguyen/5684403
Task 7: Create Database class
- Enter code: https://gist.github.com/leonguyen/5684414
Task 8: Create UserDA class
- Enter code: https://gist.github.com/leonguyen/5692560
Task 9: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5692570
Lab 03.3
Internal.External
Outline
- Internal.External with File
- External with SQLite
Storage
- Internal storage are private to your application and other
applications cannot access them (nor can the user). When the
user uninstalls your application, these files are removed.
- External storage such as SD card can also store application
data, 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.
Exercise 1

Internal.External with File
Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5452672
Task 2: Register Storage permission
- Enter code: https://gist.github.com/leonguyen/5452728
Task 3: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5452749
Task 4: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/6BE2BEnoZKM
Task 4: Execute your program (cont)
Exercise 2

External with SQLite
Task 1: Create Database class
- Enter code: https://gist.github.com/leonguyen/5465834
Task 3: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5425557
Task 3: Execute your program
- Choose "Run As" > "Android Application"
Lab 04.1
Intent
Outline
- Intent
- Intent Explicit
Intent
- Intents are system messages, running around the inside of the
device, notifying applications of various events, from hardware state
changes (e.g.,an SD card was inserted), to incoming data (e.g., an
SMS message arrived),to application events (e.g., your activity was
launched from the device’s main menu).
- Not only can you respond to intents, but you can create your own, to
launch other activities, or to let you know when specific situations arise
(e.g., raise such-and-so intent when the user click this button).
- Intents are asynchronous messages which allow Android
components to request functionality from other components of the
Android system. For example an Activity can send an Intents to the
Android system which starts another Activity.
- Three of the core components of an application — activities, services,
and broadcast receivers — are activated through messages, called
intents.
Explicit and Implicit
- Explicit intents designate the target component by its name
(the component name field, mentioned earlier, has a value set).
Since component names would generally not be known to
developers of other applications, explicit intents are typically
used for application-internal messages.
- Implicit intents do not name a target (the field for the
component name is blank). Implicit intents are often used to
activate components in other applications.
Exercise 1

Intent
Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5473266
Task 2: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5473386
Task 3: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/tJaNGzoGUG4
Exercise 2

Intent Explicit
Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5486271
Task 2: Defining Second XML Layout
- Enter code: https://gist.github.com/leonguyen/5486303
Task 3: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5486377
Task 4: Write a SecondActivity program
- Enter code: https://gist.github.com/leonguyen/5486384
Task 5: Execute your program
- Choose "Run As" > "Android Application":
http://youtu.be/7ewZXibMFy4
Lab 04.2
Content Provider
Outline
- Content Provider
- Content Provider with Contact, Call Log Picker
- Content Provider with Settings
- Content Provider Custom
Content Provider
- ContentProvider manage access to a structured set of data. The main
methods are Query, Insert, Update and Delete.
- ContentResolver is a static proxy that communicates with a
ContentProvider to access its data, either from within the same
application or from another application.
Built-In Provider
- Android offers access to a wide range of system and user data using
ContentProviders.
- Browser – bookmarks and browser history (requires permission
READ_HISTORY_BOOKMARKS and/or
WRITE_HISTORY_BOOKMARKS).
- CallLog – recent calls made or received with the device.
- Contacts – detailed information from the user’s contact list, including
people, phones, photos & groups.
- MediaStore – contents of the user’s device: audio (albums, artists,
genres, playlists), images (including thumbnails) & video.
- Settings – system-wide device settings and preferences.
- UserDictionary – contents of the user-defined dictionary used for
predictive text input.
- Voicemail – history of voicemail messages.
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
Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5519593
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/5519616
Task 4: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/CzhJTPPx6oI
Exercise 3

Content Provider with Settings
Task 1: Defining Main XML Layout
- Enter code: https://gist.github.com/leonguyen/5489929
Task 2: Defining Item XML
- Enter code: https://gist.github.com/leonguyen/5489952
Task 3: Set Contact permission
- Enter code: https://gist.github.com/leonguyen/5487519
Task 4: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5489972
Task 5: Execute your program
- Choose "Run As" > "Android Application": http://youtu.be/q--akeZkw8
Lab 04.3
Broadcast Receiver
Outline
- Broadcast Receiver
- Broadcast Receiver with Custom Intent
- Broadcast Receiver with Incoming SMS
- Broadcast Receiver with Incoming Phone Call
Broadcast Receiver
- Broadcast Receiver simply respond to broadcast messages from
other applications or from the system itself. These messages are
sometime called events or intents.
System Events
Event Constant

Description

android.intent.action.BATTERY_CHANGED

Sticky broadcast containing the charging state, level,
and other information about the battery.

android.intent.action.BATTERY_LOW

Indicates low battery condition on the device.

android.intent.action.BATTERY_OKAY

Indicates the battery is now okay after being low.

android.intent.action.BOOT_COMPLETED

This is broadcast once, after the system has finished
booting.

android.intent.action.BUG_REPORT

Show activity for reporting a bug.

android.intent.action.CALL

Perform a call to someone specified by the data.

android.intent.action.CALL_BUTTON

The user pressed the "call" button to go to the dialer or
other appropriate UI for placing a call.

android.intent.action.DATE_CHANGED

The date has changed.

android.intent.action.REBOOT

Have the device reboot.
Exercise 1

Broadcast Receiver
Task 1: Create Broadcast Receiver class
- Enter code: https://gist.github.com/leonguyen/5500078
Task 2: Register Broadcast Receiver permission
- Enter code: https://gist.github.com/leonguyen/5500092
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
- Enter code: https://gist.github.com/leonguyen/5500996
Task 2: Create Broadcast Receiver class
- Enter code: https://gist.github.com/leonguyen/5501217
Task 3: Register Broadcast Receiver permission
- Enter code: https://gist.github.com/leonguyen/5501232
Task 4: Write a MainActivity program
- Enter code: https://gist.github.com/leonguyen/5501294
Task 5: Execute your program
- Choose "Run As" > "Android Application": http://youtu.
be/SyLzgtC0Rgw
Exercise 3

Broadcast Receiver with Incoming SMS
Task 1: Create Broadcast Receiver class
- Enter code: https://gist.github.com/leonguyen/5506820
Task 2: Register Broadcast Receiver permission
- Enter code: https://gist.github.com/leonguyen/5506839
Task 3: Execute your program
- Choose "Run As" > "Android Application": http://youtu.be/CEKaJUV5ZM
Exercise 4

Broadcast Receiver with Incoming Phone Call
Task 1: Create Broadcast Receiver class
- Enter code: https://gist.github.com/leonguyen/5506917
Task 2: Register Broadcast Receiver permission
- Enter code: https://gist.github.com/leonguyen/5506953
Task 3: Execute your program
- Choose "Run As" > "Android Application":
http://youtu.be/Rj1I04fsQQk
Lab 05
An introduction to PhoneGap
References
- Getting started with PhoneGap in Eclipse for Android (adobe.
ly/H0NyLg)
- PhoneGap From Scratch (bit.ly/H0NDOW)
- Build a Feed Reader (bit.ly/1bDCxsZ)
Outline
- Download and install
- Configure the project
- Write a Hellworld program
Exercise 1

Download and install
Overview
Task 1 - Download
- Goto download site http://phonegap.com/install/
Exercise 2

Configure the project
Task 1: Create ‘www’ folder
- Create the ‘www’ folder under assets folder.
Task 2: Copy PhoneGap libraries
- Copy ‘cordova.js’ and ‘cordova.js’ to Android project.
Exercise 3

Write a Helloworld program
Task 1: Create index.html
- Create the ‘index.html’ under ‘assets/www’ folder then enter
code: gist.github.com/leonguyen/7036244
Task 2: Add to Build Path
- Right click on ‘cordova.jar’ then select Add to Build Path
Task 3: Update Activity class
- Enter code: gist.github.com/leonguyen/7036322
Task 4: Configure the project metadata
- Enter code: gist.github.com/leonguyen/7036370
Task 4: Configure the project metadata (2)
Task 5: Run
- Choose "Run As" > "Android Application".

Weitere ähnliche Inhalte

Was ist angesagt?

How to create android applications
How to create android applicationsHow to create android applications
How to create android applicationsTOPS Technologies
 
01 04 - android set up and creating an android project
01  04 - android set up and creating an android project01  04 - android set up and creating an android project
01 04 - android set up and creating an android projectSiva Kumar reddy Vasipally
 
Next Step, Android Studio!
Next Step, Android Studio!Next Step, Android Studio!
Next Step, Android Studio!Édipo Souza
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspectiveGunjan Kumar
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentReto Meier
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaSandeep Tol
 
Android development session 5 - Debug android studio
Android development   session 5 - Debug android studioAndroid development   session 5 - Debug android studio
Android development session 5 - Debug android studioFarabi Technology Middle East
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon Berlin
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in Sandeep Tol
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersAmbarish Hazarnis
 
Android, Gradle & Dependecies
Android, Gradle & DependeciesAndroid, Gradle & Dependecies
Android, Gradle & DependeciesÉdipo Souza
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumTechday7
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guideMan Chan
 
[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache CordovaHazem Saleh
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium IntroNicholas Jansma
 

Was ist angesagt? (20)

How to create android applications
How to create android applicationsHow to create android applications
How to create android applications
 
01 04 - android set up and creating an android project
01  04 - android set up and creating an android project01  04 - android set up and creating an android project
01 04 - android set up and creating an android project
 
Next Step, Android Studio!
Next Step, Android Studio!Next Step, Android Studio!
Next Step, Android Studio!
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in Java
 
Android development session 5 - Debug android studio
Android development   session 5 - Debug android studioAndroid development   session 5 - Debug android studio
Android development session 5 - Debug android studio
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
Android, Gradle & Dependecies
Android, Gradle & DependeciesAndroid, Gradle & Dependecies
Android, Gradle & Dependecies
 
#Fame case study
#Fame case study#Fame case study
#Fame case study
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Mobile Worshop Lab guide
Mobile Worshop Lab guideMobile Worshop Lab guide
Mobile Worshop Lab guide
 
[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova[ApacheCon 2016] Advanced Apache Cordova
[ApacheCon 2016] Advanced Apache Cordova
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
Android studio
Android studioAndroid studio
Android studio
 

Andere mochten auch

Design Collections
Design CollectionsDesign Collections
Design CollectionsLeo Nguyen
 
Ladou Corporate Presentation
Ladou Corporate PresentationLadou Corporate Presentation
Ladou Corporate PresentationLuciead
 
Mobile Resources
Mobile ResourcesMobile Resources
Mobile ResourcesLeo Nguyen
 
After Effect Lab
After Effect LabAfter Effect Lab
After Effect LabLeo Nguyen
 
Android.AntiSpam Lab
Android.AntiSpam LabAndroid.AntiSpam Lab
Android.AntiSpam LabLeo Nguyen
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter LabLeo Nguyen
 
TechKnowledge.vn giới thiệu
TechKnowledge.vn giới thiệuTechKnowledge.vn giới thiệu
TechKnowledge.vn giới thiệuLeo Nguyen
 
PolyOS - Giải pháp cho chuyên gia mạng máy tính
PolyOS - Giải pháp cho chuyên gia mạng máy tínhPolyOS - Giải pháp cho chuyên gia mạng máy tính
PolyOS - Giải pháp cho chuyên gia mạng máy tínhLeo Nguyen
 

Andere mochten auch (16)

Design Collections
Design CollectionsDesign Collections
Design Collections
 
Laravel Lab
Laravel LabLaravel Lab
Laravel Lab
 
Ladou Corporate Presentation
Ladou Corporate PresentationLadou Corporate Presentation
Ladou Corporate Presentation
 
Spring Lab
Spring LabSpring Lab
Spring Lab
 
Zend Lab
Zend LabZend Lab
Zend Lab
 
Mobile Resources
Mobile ResourcesMobile Resources
Mobile Resources
 
After Effect Lab
After Effect LabAfter Effect Lab
After Effect Lab
 
Android.AntiSpam Lab
Android.AntiSpam LabAndroid.AntiSpam Lab
Android.AntiSpam Lab
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter Lab
 
PhoneGap Lab
PhoneGap LabPhoneGap Lab
PhoneGap Lab
 
Web Resources
Web ResourcesWeb Resources
Web Resources
 
PHP Lab
PHP LabPHP Lab
PHP Lab
 
Software financiero
Software financieroSoftware financiero
Software financiero
 
Software financiero
Software financieroSoftware financiero
Software financiero
 
TechKnowledge.vn giới thiệu
TechKnowledge.vn giới thiệuTechKnowledge.vn giới thiệu
TechKnowledge.vn giới thiệu
 
PolyOS - Giải pháp cho chuyên gia mạng máy tính
PolyOS - Giải pháp cho chuyên gia mạng máy tínhPolyOS - Giải pháp cho chuyên gia mạng máy tính
PolyOS - Giải pháp cho chuyên gia mạng máy tính
 

Ähnlich wie Android Lab

Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramioslesulvy
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by steppriya Nithya
 
Android application development
Android application developmentAndroid application development
Android application developmentslidesuren
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Module-I_Introduction-to-Android.pptx
Module-I_Introduction-to-Android.pptxModule-I_Introduction-to-Android.pptx
Module-I_Introduction-to-Android.pptxlancelotlaytan1996
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfShaiAlmog1
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 
Part 2 android application development 101
Part 2 android application development 101Part 2 android application development 101
Part 2 android application development 101Michael Angelo Rivera
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Session 2 prepare android development environment
Session 2   prepare android development environmentSession 2   prepare android development environment
Session 2 prepare android development environmentAdham Enaya
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgetsPrajyot Mainkar
 

Ähnlich wie Android Lab (20)

Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
Synapseindia android apps application
Synapseindia android apps applicationSynapseindia android apps application
Synapseindia android apps application
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by step
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Module-I_Introduction-to-Android.pptx
Module-I_Introduction-to-Android.pptxModule-I_Introduction-to-Android.pptx
Module-I_Introduction-to-Android.pptx
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdf
 
Google Android
Google AndroidGoogle Android
Google Android
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Android
AndroidAndroid
Android
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Part 2 android application development 101
Part 2 android application development 101Part 2 android application development 101
Part 2 android application development 101
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android
Android Android
Android
 
Session 2 prepare android development environment
Session 2   prepare android development environmentSession 2   prepare android development environment
Session 2 prepare android development environment
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 

Kürzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Android Lab

  • 2. 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
  • 3. Outline (cont) - Lab 05: An introduction to PhoneGap
  • 4. 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)
  • 5. 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)
  • 6. References (cont) - Android Mobile Develope (http://bit.ly/148e7Wr) - Android Patterns (www.androidpatterns.com) - Tutorial Point (http://bit.ly/13vMmF9) - Android Education (android-ed.blogspot.com) - Tech Blog On (http://bit.ly/11f2Wa5) - Android App Market (www.android-app-market.com) - Java Code Geeks (http://bit.ly/18IFOsh) - New Think Tank (http://bit.ly/13cXN5G) - Android Aspect (www.androidaspect.com) - Android Hub 4 You (www.androidhub4you.com) - Surviving With Android (www.survivingwithandroid.com) - Sachin Shelke (http://bit.ly/10R5kUG) - Knowledge of Experience (http://bit.ly/13vNLv7)
  • 7. References (cont) - Android For Beginners (http://bit.ly/Zm2wRS) - Clean Code (http://bit.ly/19yBbzX) - Think Android (thinkandroid.wordpress.com) - Romain Guy (http://bit.ly/13vOc91) - Mr Bool (mrbool.commrbool.com) - Android Guide Tips (http://bit.ly/Zm2Rns) - The Android (http://bit.ly/12XIJHl) - Android Tuts (androidituts.com) - Traintelco (bit.ly/15YprUo) - Pavand (bit.ly/15sWbqS)
  • 9. Outline - Download and install JDK - Download Android Developer Tools (ADT) - Write a Helloworld program (Use ADT) - Download Android Studio - Write a Helloworld program (Use AS)
  • 10. Exercise 1 Download and install JDK
  • 12. Task 1 - Download JDK - Goto Java download site http://www.oracle. com/technetwork/java/javase/downloads/index.html
  • 13. Task 1 - Download JDK (cont) - Select Java Platform (JDK), choose your operation platform (eg Window X86) and download it
  • 14. Task 2 - Install JDK - Run the downloaded installer, which installs both the JDK (Java Development Kit) and JRE (Java Runtime). By default the JDK and JRE will be installed into directories C:Program FilesJava
  • 15. Task 3 - Config PATH environment variables - Windows Operating System searches the current directory and the directories listed in the PATH environment variable for executable programs invoked from the CMD shell. It helps programmer can compile Java code in CMD shell. - Click the "Start" button > "Control Panel" > "System" > (Vista/7 only) "Advanced system settings"
  • 16. Task 3 - Config PATH .. (cont)
  • 17. 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.
  • 19. Task 1: Download ADT - Go to: http://developer.android.com/sdk/index.html
  • 20. Task 2: Open Android SDK Manager - Install Android API
  • 21. Task 3: Create Android Virtual Device - Goto Tools > Manage AVDs
  • 22. Task 3: Create Android Virtual Device (cont) - Choose New.
  • 23. Task 3: Create Android Virtual Device (cont) - Choose Start.
  • 24. Exercise 3 Write a Helloworld program (Use ADT)
  • 25. Task 1: Run Eclipse ADT - Open eclipse.exe
  • 26. Task 2: Create Android Application - Go to File > New > Android Application Project
  • 27. Task 2: Create Android Application (cont)
  • 28. Task 2: Create Android Application (cont) - The Main XML Layout: https://gist.github. com/leonguyen/5351679
  • 29. Task 3: Write a MainActivity program - Open MainActivity.java: https://gist.github. com/leonguyen/5351695
  • 30. Task 3: Write a MainActivity program (cont) - Enter code: https://gist.github.com/leonguyen/5301102
  • 31. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 32. Task 4: Execute your program (cont) - Select and start AVD.
  • 33. Task 4: Execute your program (cont) - Choose running Android device.
  • 34. Task 4: Execute your program (cont) - Choose AndroidLab.
  • 36. Task 1: Download AS - Go to: http://developer.android.com/sdk/installing/studio.html
  • 37. Exercise 5 Write a Helloworld program (Use AS)
  • 38. Task 1: Run AS - Open Android Studio shortcut.
  • 39. Task 2: Create Android Application - Select New Project...
  • 40. Task 2: Create Android Application (cont) - Input Android application name.
  • 41. Task 2: Create Android Application (cont) - Input Android application icon.
  • 42. Task 2: Create Android Application (cont) - Select Android application activity.
  • 43. Task 2: Create Android Application (cont) - Input Android application activity name.
  • 45. Outline - Linear Layout - Linear Layout - Message - Linear Layout - Quiz - Linear Layout - Login - Linear Layout - Register - Linear Layout - Home
  • 47. Linear Layout - A layout is a view group that aligns all children in a single direction, vertically or horizontally. - All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padding). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child.
  • 48. Layout weight - To create a linear layout in which each child uses the same amount of space on the screen, 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). Then set the android:layout_weight of each view to "1".
  • 49. Task 1: Create XML Layout - Right click on the res/layout folder.
  • 50. Task 2: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5308746
  • 51. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 53. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5325407
  • 54. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 56. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5325424
  • 57. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 59. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5329665
  • 60. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 62. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5329865
  • 63. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 65. Task 1: Create XML Drawable - Right click on the res folder.
  • 66. Task 2: Defining an XML Drawable - Enter code: https://gist.github.com/leonguyen/5516102
  • 67. Task 3: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5515898
  • 68. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 70. Outline - Relative Layout - Relative Layout - Reminder - Relative Layout - Work - Table Layout - Table Layout - Weather - Scroll View
  • 72. Relative Layout - A layout is a view group that displays child views in relative positions.
  • 73. Positioning Views - 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_centerVertical If "true", centers this child vertically within its 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. These are just a few examples. All layout attributes are documented at RelativeLayout.LayoutParams.
  • 74. Task 1: Create XML Layout - Right click on the res/layout folder.
  • 75. Task 2: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5309283
  • 76. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 78. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5325475
  • 79. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 81. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5329563
  • 82. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 84. Table Layout - A layout that arranges its children into rows and columns. A TableLayout consists of a number of TableRow objects, each defining a row (actually, you can have other children, which will be explained below). TableLayout containers do not display border lines for their rows, columns, or cells. Each row has zero or more cells; each cell can hold one View object. The table has as many columns as the row with the most cells. A table can leave cells empty. Cells can span columns, as they can in HTML.
  • 85. Task 1: Create XML Layout - Right click on the res/layout folder.
  • 86. Task 2: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5325531
  • 87. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 89. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5325537
  • 90. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 92. Task 1: Create XML Layout - Right click on the res/layout folder.
  • 93. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5331192
  • 94. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 96. Outline - List View - List View with Custom Layout - List View with Context Menu - List View with Custom Adapter - List View with Custom ArrayList - List View with Activity - List View with Activity and Custom Main Layout - List View with Thread
  • 98. 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.
  • 99. 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.
  • 100. Task 1: Create ListView Activity - Enter code: https://gist.github.com/leonguyen/5335106
  • 101. Task 2: Execute your program - Choose "Run As" > "Android Application"
  • 102. Exercise 2 List View with Custom Layout
  • 103. Task 1: Create XML Layout - Right click on the res/layout folder.
  • 104. Task 2: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5335460
  • 105. Task 3: Create ListView Activity - Enter code: https://gist.github.com/leonguyen/5335493
  • 106. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 107. Exercise 3 List View with Context Menu
  • 108. Task 1: Create ListView Activity - Enter code: https://gist.github.com/leonguyen/5335493
  • 109. Task 2: Register ListView for ContextMenu - Enter code.
  • 110. Task 3: Create Context Menu XML - Right click on the res/menu folder.
  • 111. Task 4: Defining an Context Menu XML - Enter code: https://gist.github.com/leonguyen/5345210
  • 112. Task 3: Create onCreateContextMenu() - Right click on editor.
  • 113. Task 4: Create onContextItemSelected() - Right click on editor.
  • 114. Task 5: Add menu - Enter code: https://gist.github.com/leonguyen/5344253
  • 115. Task 6: Execute your program - Choose "Run As" > "Android Application"
  • 116. Exercise 3 List View with Custom Adapter
  • 117. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5335460
  • 118. Task 2: Create Custom Adapter class - Enter code: https://gist.github.com/leonguyen/5450429
  • 119. Task 3: Create List View Activity - Enter code: https://gist.github.com/leonguyen/5450482
  • 120. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 121. Exercise 4 List View with Custom ArrayList
  • 122. Task 1: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5632592
  • 123. Task 2: Create Custom Adapter class - Enter code: https://gist.github.com/leonguyen/5632608
  • 124. Task 3: Create List View Activity - Enter code: https://gist.github.com/leonguyen/5632651
  • 125. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 126. Loader - 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. - When the CursorLoader receives the Cursor result, the LoaderCallbacks receives a callback to onLoadFinished(), which is where you update your Adapter with the new Cursor and the list view then displays the results.
  • 127. SimpleCursorAdapter - Use this adapter when your data comes from a Cursor. When using SimpleCursorAdapter, 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.
  • 131. Task 1: Create Dialog XML Layout - Right click on the res/menu folder.
  • 132. Task 3: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5353541
  • 133. Task 3: Create onCreateContextMenu() - Right click on editor.
  • 134. Task 4: Add Option Menu - Enter code: https://gist.github.com/leonguyen/5353562
  • 135. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 137. Outline - Alert Dialog - Dialog with Custom Layout
  • 139. Task 1: Create Button in Main Layout - Edit file res/layout/activity_main.xml: https://gist.github. com/leonguyen/5351375
  • 140. Task 2: Create Alert Dialog program - Enter code: https://gist.github.com/leonguyen/5353961
  • 141. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 142. Exercise 2 Dialog with Custom Layout
  • 143. Task 1: Create Button in Main Layout - Edit file res/layout/activity_main.xml: https://gist.github. com/leonguyen/5351375
  • 144. Task 2: Create Dialog XML Layout - Right click on the res/layout folder.
  • 145. Task 3: Defining an XML Layout - Enter code: https://gist.github.com/leonguyen/5351420
  • 146. Task 3: Create Custom Dialog program - Enter code: https://gist.github.com/leonguyen/5351822
  • 147. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 150. Widget - App Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic updates. - To create an App Widget, you need the following: + AppWidgetProviderInfo object Describes the metadata for an App Widget, such as the App Widget's layout, update frequency, and the AppWidgetProvider class. + AppWidgetProvider class implementation Defines the basic methods that allow you to programmatically interface with the App Widget, based on broadcast events. + View layout Defines the initial layout for the App Widget, defined in XML.
  • 152. Task 1: Defining an Widget Drawable - Enter code: https://gist.github.com/leonguyen/5667758
  • 153. Task 2: Defining an Widget XML Layout - Enter code: https://gist.github.com/leonguyen/5667769
  • 154. Task 3: Create AppWidgetProviderInfo Metadata - Right click on the res/xml folder.
  • 155. Task 4: Defining AppWidgetProviderInfo Metadata - Enter code: https://gist.github.com/leonguyen/5667832
  • 156. Task 5: Create Widget Provider program - Enter code: https://gist.github.com/leonguyen/5667853
  • 157. Task 6: Declaring an App Widget in the Manifest - Enter code: https://gist.github.com/leonguyen/5667862
  • 158. Task 7: Execute your program - Choose "Run As" > "Android Application": http://youtu.be/LTsvhrDoDg
  • 160. Outline - Shared Preferences - Shared Preferences - Preference Activity
  • 161. Shared Preferences - 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, floats, ints, longs, and strings. This data will persist across user sessions (even if your application is killed). + getSharedPreferences() - Use this if you need multiple preferences files identified by name, which you specify with the first parameter. + getPreferences() - Use this if you need only one preferences file for your Activity. Because this will be the only preferences file for your Activity, you don't supply a name.
  • 163. Task 1: Defining Main XML Layout - Edit file res/layout/activity_main.xml: https://gist.github. com/leonguyen/5402754
  • 164. Task 2: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5402780
  • 165. Task 3: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/Gj2VkO8zxaM
  • 166. Exercise 2 Shared References - Reference Activity
  • 167. Task 1: Defining Main XML Menu - Edit file res/menu/main.xml: https://gist.github. com/leonguyen/5409423
  • 168. Task 2: Create Array XML Value - Right click on the res/values folder.
  • 169. Task 3: Defining Array XML Value - Edit file res/xml/arrays.xml: https://gist.github.com/leonguyen/5409973
  • 170. Task 4: Create Preference XML - Right click on the res/xml folder.
  • 171. Task 5: Defining Preference XML - Edit file res/xml/preferences.xml: https://gist.github.com/leonguyen/5409597
  • 172. Task 6: Create PreferenceActivity - Enter code: https://gist.github.com/leonguyen/5409613
  • 173. Task 7: Defining Android Manifest - Enter code: https://gist.github.com/leonguyen/5409836
  • 174. Task 8: Write MainActivity program - Enter code: https://gist.github.com/leonguyen/5410070
  • 175. Task 9: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/CDyIaC3woZU
  • 176. Task 9: Execute your program (cont)
  • 177. Task 9: Execute your program (cont)
  • 179. Outline - SQLite - SQLite with Multiple Tables - SQLite with CRUD - SQLite with Multiple Tables CRUD - SQLite with Design Pattern
  • 181. Task 1: Create Database class - Enter code: https://gist.github.com/leonguyen/5425508
  • 182. Task 2: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5425557
  • 183. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 184. Exercise 2 SQLite with Multiple Tables
  • 185. Task 1: Create Entity class - Enter code: https://gist.github.com/leonguyen/5425418
  • 186. Task 2: Create Database Object class - Enter code: https://gist.github.com/leonguyen/5524350
  • 187. Task 3: Create Database Helper class - Enter code: https://gist.github.com/leonguyen/5524390
  • 188. Task 4: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5524451
  • 189. Task 5: Execute your program - Choose "Run As" > "Android Application"
  • 191. Task 1: Create User Entity class - Enter code: https://gist.github.com/leonguyen/5425418
  • 192. Task 2: Create UserDA class with CRUD - Enter code: https://gist.github.com/leonguyen/5425683
  • 193. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5425704
  • 194. Task 4: Execute your program - Choose "Run As" > "Android Application"
  • 195. Exercise 4 SQLite with Multiple Tables CRUD
  • 196. Task 1: Create User Entity class - Enter code: https://gist.github.com/leonguyen/5425418
  • 197. Task 2: Create UserDA class with CRUD - Enter code: https://gist.github.com/leonguyen/5524722
  • 198. Task 3: Create Database Helper class - Enter code: https://gist.github.com/leonguyen/5525519
  • 199. Task 4: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5525541
  • 200. Task 5: Execute your program - Choose "Run As" > "Android Application"
  • 201. Exercise 5 SQLite with Design Pattern
  • 203. Task 1: Create Person Abstract class - Enter code: https://gist.github.com/leonguyen/5683910
  • 204. Task 2: Create User Entity class - Enter code: https://gist.github.com/leonguyen/5683921
  • 205. Task 3: Create DB Config Enum - Enter code: https://gist.github.com/leonguyen/5683976
  • 206. Task 4: Create Table Helper class - Enter code: https://gist.github.com/leonguyen/5684167
  • 207. Task 5: Create User Table class - Enter code: https://gist.github.com/leonguyen/5684181
  • 208. Task 6: Create Data Manipulation Object class - Enter code: https://gist.github.com/leonguyen/5684403
  • 209. Task 7: Create Database class - Enter code: https://gist.github.com/leonguyen/5684414
  • 210. Task 8: Create UserDA class - Enter code: https://gist.github.com/leonguyen/5692560
  • 211. Task 9: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5692570
  • 213. Outline - Internal.External with File - External with SQLite
  • 214. Storage - Internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. - External storage such as SD card can also store application data, 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.
  • 216. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5452672
  • 217. Task 2: Register Storage permission - Enter code: https://gist.github.com/leonguyen/5452728
  • 218. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5452749
  • 219. Task 4: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/6BE2BEnoZKM
  • 220. Task 4: Execute your program (cont)
  • 222. Task 1: Create Database class - Enter code: https://gist.github.com/leonguyen/5465834
  • 223. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5425557
  • 224. Task 3: Execute your program - Choose "Run As" > "Android Application"
  • 227. Intent - Intents are system messages, running around the inside of the device, notifying applications of various events, from hardware state changes (e.g.,an SD card was inserted), to incoming data (e.g., an SMS message arrived),to application events (e.g., your activity was launched from the device’s main menu). - Not only can you respond to intents, but you can create your own, to launch other activities, or to let you know when specific situations arise (e.g., raise such-and-so intent when the user click this button). - Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system. For example an Activity can send an Intents to the Android system which starts another Activity. - Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents.
  • 228. Explicit and Implicit - Explicit intents designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages. - Implicit intents do not name a target (the field for the component name is blank). Implicit intents are often used to activate components in other applications.
  • 230. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5473266
  • 231. Task 2: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5473386
  • 232. Task 3: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/tJaNGzoGUG4
  • 234. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5486271
  • 235. Task 2: Defining Second XML Layout - Enter code: https://gist.github.com/leonguyen/5486303
  • 236. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5486377
  • 237. Task 4: Write a SecondActivity program - Enter code: https://gist.github.com/leonguyen/5486384
  • 238. Task 5: Execute your program - Choose "Run As" > "Android Application": http://youtu.be/7ewZXibMFy4
  • 240. Outline - Content Provider - Content Provider with Contact, Call Log Picker - Content Provider with Settings - Content Provider Custom
  • 241. Content Provider - ContentProvider manage access to a structured set of data. The main methods are Query, Insert, Update and Delete. - ContentResolver is a static proxy that communicates with a ContentProvider to access its data, either from within the same application or from another application.
  • 242. Built-In Provider - Android offers access to a wide range of system and user data using ContentProviders. - Browser – bookmarks and browser history (requires permission READ_HISTORY_BOOKMARKS and/or WRITE_HISTORY_BOOKMARKS). - CallLog – recent calls made or received with the device. - Contacts – detailed information from the user’s contact list, including people, phones, photos & groups. - MediaStore – contents of the user’s device: audio (albums, artists, genres, playlists), images (including thumbnails) & video. - Settings – system-wide device settings and preferences. - UserDictionary – contents of the user-defined dictionary used for predictive text input. - Voicemail – history of voicemail messages.
  • 244. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5487428
  • 245. Task 2: Register Contact permission - Enter code: https://gist.github.com/leonguyen/5487519
  • 246. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5487527
  • 247. Task 4: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/21AQ5NFtv-w
  • 248. Exercise 2 Content Provider with Contact, Call Log Picker
  • 249. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5519593
  • 250. Task 2: Register Contact permission - Enter code: https://gist.github.com/leonguyen/5487519
  • 251. Task 3: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5519616
  • 252. Task 4: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/CzhJTPPx6oI
  • 253. Exercise 3 Content Provider with Settings
  • 254. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5489929
  • 255. Task 2: Defining Item XML - Enter code: https://gist.github.com/leonguyen/5489952
  • 256. Task 3: Set Contact permission - Enter code: https://gist.github.com/leonguyen/5487519
  • 257. Task 4: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5489972
  • 258. Task 5: Execute your program - Choose "Run As" > "Android Application": http://youtu.be/q--akeZkw8
  • 260. Outline - Broadcast Receiver - Broadcast Receiver with Custom Intent - Broadcast Receiver with Incoming SMS - Broadcast Receiver with Incoming Phone Call
  • 261. Broadcast Receiver - Broadcast Receiver simply respond to broadcast messages from other applications or from the system itself. These messages are sometime called events or intents.
  • 262. System Events Event Constant Description android.intent.action.BATTERY_CHANGED Sticky broadcast containing the charging state, level, and other information about the battery. android.intent.action.BATTERY_LOW Indicates low battery condition on the device. android.intent.action.BATTERY_OKAY Indicates the battery is now okay after being low. android.intent.action.BOOT_COMPLETED This is broadcast once, after the system has finished booting. android.intent.action.BUG_REPORT Show activity for reporting a bug. android.intent.action.CALL Perform a call to someone specified by the data. android.intent.action.CALL_BUTTON The user pressed the "call" button to go to the dialer or other appropriate UI for placing a call. android.intent.action.DATE_CHANGED The date has changed. android.intent.action.REBOOT Have the device reboot.
  • 264. Task 1: Create Broadcast Receiver class - Enter code: https://gist.github.com/leonguyen/5500078
  • 265. Task 2: Register Broadcast Receiver permission - Enter code: https://gist.github.com/leonguyen/5500092
  • 266. Task 3: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/CuF9IakbEl0
  • 267. Exercise 2 Broadcast Receiver with Custom Intent
  • 268. Task 1: Defining Main XML Layout - Enter code: https://gist.github.com/leonguyen/5500996
  • 269. Task 2: Create Broadcast Receiver class - Enter code: https://gist.github.com/leonguyen/5501217
  • 270. Task 3: Register Broadcast Receiver permission - Enter code: https://gist.github.com/leonguyen/5501232
  • 271. Task 4: Write a MainActivity program - Enter code: https://gist.github.com/leonguyen/5501294
  • 272. Task 5: Execute your program - Choose "Run As" > "Android Application": http://youtu. be/SyLzgtC0Rgw
  • 273. Exercise 3 Broadcast Receiver with Incoming SMS
  • 274. Task 1: Create Broadcast Receiver class - Enter code: https://gist.github.com/leonguyen/5506820
  • 275. Task 2: Register Broadcast Receiver permission - Enter code: https://gist.github.com/leonguyen/5506839
  • 276. Task 3: Execute your program - Choose "Run As" > "Android Application": http://youtu.be/CEKaJUV5ZM
  • 277. Exercise 4 Broadcast Receiver with Incoming Phone Call
  • 278. Task 1: Create Broadcast Receiver class - Enter code: https://gist.github.com/leonguyen/5506917
  • 279. Task 2: Register Broadcast Receiver permission - Enter code: https://gist.github.com/leonguyen/5506953
  • 280. Task 3: Execute your program - Choose "Run As" > "Android Application": http://youtu.be/Rj1I04fsQQk
  • 281. Lab 05 An introduction to PhoneGap
  • 282. References - Getting started with PhoneGap in Eclipse for Android (adobe. ly/H0NyLg) - PhoneGap From Scratch (bit.ly/H0NDOW) - Build a Feed Reader (bit.ly/1bDCxsZ)
  • 283. Outline - Download and install - Configure the project - Write a Hellworld program
  • 286. Task 1 - Download - Goto download site http://phonegap.com/install/
  • 288. Task 1: Create ‘www’ folder - Create the ‘www’ folder under assets folder.
  • 289. Task 2: Copy PhoneGap libraries - Copy ‘cordova.js’ and ‘cordova.js’ to Android project.
  • 290. Exercise 3 Write a Helloworld program
  • 291. Task 1: Create index.html - Create the ‘index.html’ under ‘assets/www’ folder then enter code: gist.github.com/leonguyen/7036244
  • 292. Task 2: Add to Build Path - Right click on ‘cordova.jar’ then select Add to Build Path
  • 293. Task 3: Update Activity class - Enter code: gist.github.com/leonguyen/7036322
  • 294. Task 4: Configure the project metadata - Enter code: gist.github.com/leonguyen/7036370
  • 295. Task 4: Configure the project metadata (2)
  • 296. Task 5: Run - Choose "Run As" > "Android Application".