Android Development
Summary
Presenter: Trinh Dang
SME: Dung Nguyen
Table of Content
▪ Why Android?
▪
Android Development
▪
Android Activity
▪
Android UI and Event
▪
Android ListView and Menu Adapter
▪
Android Web Services
▪
Android SQLite
▪ Android Map and Location
1. Why Android?
▪
Android is a mobile operating system based on
the Linux Kernel that is currently developed by
Google.
▪
As of July 2013 the Google Play store has had
over 1 million Android apps published, and over
50 billion apps downloaded.
▪
At Google I/O 2014, the company revealed that
there were over 1 billion active monthly Android
users.
2. Android Development
▪
The latest version of Android OS is Android 4.4.2.
▪
Android provides a rich application framework that
allows you to build innovative apps and games for
mobile devices in a Java language environment.
▪
Eclipse with ADT bundle (or Android Studio)
▪
Android Emulator: Genymotion (Bluestack or
Android Virtual Device on Eclipse)
3. Android Activity
▪
An Activity is an application component that provides a
screen with which users can interact in order to do
something, such as dial the phone, take a photo, send
an email, or view a map.
▪
An activity is launched by passing an Intent object to
Context.startActivity()
or Activity.startActivityForResult()
3. Android Activity
▪
It is simple to run one activity from other, and some data need
to be sent to the new. Bundle is used to passing data.
4. Android UI and Event
▪
Android UI using a
hierarchy of View and
ViewGroup nodes, as
shown in the diagram
beside
4. Android UI and Event
▪
Using an XML layout file to define layout and express the view.
▪
All xml layout files are in ProjectName/res/layout
4. Android UI and Event
▪
Define an event listener and register it with the
View class. The View class contains a collection of
nested interfaces named On<something>Listener
e.g. View.OnClickListener(). These interfaces, called
event listeners.
▪
Override an existing callback method for the View
e.g. onTouchEvent(). This is usewhen implementing
own View class. This way is called event handlers
5. Android ListView and Menu Adapter
5. Android ListView and Menu Adapter
▪
Bind data source into ListView
SimpleAdapter for static data (Maps)
SimpleCursorAdapter for Cursor query result
5. Android ListView and Menu Adapter
SimpleCursorAdapter class
Specify columns
Specify views to display the columns
Specify the XML file that defines the appearance of these views
Constructor
SimpleCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to)Constructor
5. Android ListView and Menu Adapter
Menu Adapter
Options Menu: The primary menu for an Activity, which appears
when the user presses the device MENU key
Context Menu: a floating list of menu items that appears when the
user performs a long-press on a View
Submenu: a floating list of menu items that the user opens by
pressing a menu item in the Options Menu or a context menu
5. Android ListView and Menu Adapter
▪
Inflating a Menu Resource: create menu by override
method onCreateOptionsMenu(Menu menu). This
method is called only the first time the Options
Menu is opened
▪
Handle select a menu item from the Options Menu
by override method onOptionsItemSelected
(MenuItem item)
6. Android Web Services
▪
Parsing XML data
–
DOM
–
SAX
–
Android SAX
–
XML Pull
6. Android Web Services
▪ Parsing JSON data
▪
JSON library
▪
GSON library
▪
Gson is a Java library that can be used to convert Java
Objects into its JSON representation. It can also be used to
convert a JSON string to an equivalent Java object. Gson
can work with arbitrary Java objects including pre-existing
objects that you do not have source-code of.
7. Android SQLite
▪
SQLite is a database support structured data
▪
Android provides full support for SQLite databases. Any databases you
create will be accessible by name to any class in the application, but not
outside the application
▪
SQLite run on phone OS services, not a database server like SQL server
or MySQL. It stores data in local phone.
▪
Database file can be found at the following location
/data/data/app.package/databases/your-db-name
7. Android SQLite
▪
Insert data
public long insert (String table, String nullColumnHack, ContentValues values)
▪ Update data:
update(String table, ContentValues values, String whereClause, String[]
whereArgs)
▪ Delete data:
public int delete (String table, String whereClause, String[] whereArgs)
8. Android Map and Location
8. Android Map and Location
8. Android Map and Location
▪
Using Location Service
Thank you for your listening