Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Felight Android Professional

This presentation is created for Android Corporate Training for KnowVirtue
by

Vinay Noah

on 20 June 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Felight Android Professional

Architecture
Platform Overview
Android is a software stack for mobile devices that includes an operating system, middleware and key applications.
Vinay Noah
Felight | Group of Flamboynz Software PVT LTD
29th January 2013

Android Introduction
All applications are written using the Java language.
Email Client
SMS Program
Calendar
Maps
Browser
Contacts
Etc
Android provides a set of core applications
Cupcake (1.5)
Donut (1.5)
Éclair(2.0)
Froyo(2.2)
Gingerbread(2.3)
Honeycomb(3)

Ice Cream Sandwich (ICS)(4.0)

Jelly Bean(4.1)
Android Version History
Relying on Linux Kernel 2.6 for core system services
Memory and Process Management
Network Stack
Driver Model
Security
Providing an abstraction layer between the H/W and the rest of the S/W stack
Android S/W Stack – Linux Kernel
Providing environment on which every Android application runs

Each Android application runs in its own process, with its own instance of the Dalvik VM.

Dalvik has been written such that a device can run multiple VMs efficiently.
Dalvik Virtual Machine
Providing most of the functionality available in the core libraries of the Java language
APIs
Data Structures
Utilities
File Access
Network Access
Graphics
Etc
Core Libraries
Android S/W Stack - Runtime
Features
App Framework
Android S/W Stack - Application
MarketShare
OHA (Open Handset Alliance)
A business alliance consisting of 47 companies to develop open standards for mobile devices
Android version distribution
Heterogeneous devices
Popularity
Echo System
Open Source
Why Android is different ?
Relying on the Linux Kernel for:
Threading
Low-level memory management
Executing the Dalvik Executable (.dex) format
.dex format is optimized for minimal memory footprint.
Compilation
DVM
Including a set of C/C++ libraries used by components of the Android system
Exposed to developers through the Android application framework
Android S/W Stack - Libraries
Enabling and simplifying the reuse of components
Android S/W Stack – App Framework
Developers have full access to the same framework APIs used by the core applications.
Users are allowed to replace components.
Android is a software stack for mobile devices that includes
an operating system,
middleware and
key applications.
Hello World – My First Android App
If “Android Application project” is not available then choose “Other” in the submenu as show below.
6. Using ADB tool the .apk file will be installed to either virtual device or any other physical device connected to your sytem.
7. Finally, if the application is being signed in release mode, you must align the .apk with the zipalign tool. Aligning the final .apk decreases memory usage when the application is running on a device..
6. Once the .apk is built, it must be signed with either a debug or release key before it can be installed to a device.
5. All non-compiled resources (such as images), compiled resources, and the .dex files are sent to the apkbuilder tool to be packaged into an .apk file.
4. The dex tool converts the .class files to Dalvik byte code. Any 3rd party libraries and .class files that you have included in your project are also converted into .dex files so that they can be packaged into the final .apk file.
2. The aidl tool converts any .aidl interfaces that you have into Java interfaces.

3. All of your Java code, including the R.java and .aidl files, are compiled by the Java compiler and .class files are output.
1. The Android Asset Packaging Tool (aapt) takes your application resource files, such as the AndroidManifest.xml file and the XML files for your Activities, and compiles them. An R.java is also produced so you can reference your resources from your Java code.
A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access.
Content providers
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.
Services
An activity represents a single screen with a user interface.
Activities
Android Components Application Components (Intro Only)
A broadcast receiver is a component that responds to system-wide broadcast announcements.
Broadcast receivers
Broadcast receivers
Content providers
Services
Activities
Application components are the essential building blocks of an Android application. Not all components are actual entry points.
Android Manifest File (Registering Activities)
An activity is a single, focused thing that the user can do
Set the TextView content of MainActivity by getting the result from Intent object
MainAcivity.java page on emulator. Click on Button to go to another Activity(Activity2)
AndroidManifest.xml
Layout resource for MainActivity
We are reading image from gallery using Implicit Intent object
implicit intent manifest
We came to Activity2 using intents
UI of MainActivity
Layout resource of Activity2
Second Activity getting Intent Object with Data
Layout resource for MainActivity
OnClick go to next Activity
Explicit Intent
Custom array adapter to customize the item display in ListView.
Normal way to display components in ListView.
Handling click events
Common Layouts
Binding layout XML to Activity
Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile.
Advantage of declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior.
User Interface
The manifest file glues everything together. It is this file that explains what the application consists of, what all its main building blocks are, what permissions it requires, and so on.
Manifest File
Activity Lifecycle
Activities need to be registered in AndroidManifest.xml
Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with
setContentView(View).
Before we can start creating the UI lets first understand more about the Activity class.
Building UI with Activities
Acivity2.java
MainActivity.java class invoking other Activity for result with the help of Intent object
Intent Activity for Result
Implicit calling of our activity
onClick() processed
Intent filters inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters. Each filter describes a capability of the component, a set of intents that the component is willing to receive.
An Intent object is a bundle of information. It contains information of interest to the component that receives the intent
Intents and Intent Filters
Image Resources
Color Resources
String Array
Responding to Click Events
Extend a BaseAdapter to display a group of image and text in GridView layout
ListView is 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.
List View
A RelativeLayout is a very powerful utility for designing a user interface because it can eliminate nested view groups and keep your layout hierarchy flat, which improves performance. If you find yourself using several nested LinearLayout groups, you may be able to replace them with a single RelativeLayout.
RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left of center).
Relative Layout
LinearLayout also supports assigning a weight to individual children with the android:layout_weight attribute. This attribute assigns an "importance" value to a view in terms of how much space is should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view.
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.
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.
Linear Layout
Layouts backed by an adapter
1. By using XML resource
2. By instantiating layout elements at runtime
There are 2 ways you can create a Layout
A layout defines the visual structure for a user interface, such as the UI for an activity or app widget.
Layout
onPause()
is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data).
onCreate(Bundle)
is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically.
Two methods almost all subclasses of Activity will implement
Layout xml for Main Activity
Implicit Intents
Main Activity
String
String Resources
A button consists of text or an icon (or both text and an icon) that communicates what action occurs when the user touches it.
Buttons
Adding an input control to your UI is as simple as adding an XML element to your XML layout. For example, here's a layout with a text field and button:
Input controls are the interactive components in your app's user interface. Android provides a wide variety of controls you can use in your UI, such as buttons, text fields, seek bars, checkboxes, zoom buttons, toggle buttons, and many more.
Input Controls
Scrollview
A ScrollView is a special type of FrameLayout in that it enables users to scroll through a list of views that occupy more space than the physical display. The ScrollView can contain only one child view or ViewGroup, which normally is a LinearLayout.
Framelayout
The FrameLayout is a placeholder on screen that you can use to display a single view. Views that you add to a FrameLayout are always anchored to the top left of the layout.
TableLayout
The TableLayout groups views into rows and columns. You use the <TableRow> element to designate a row in the table.
AbsoluteLayout
The AbsoluteLayout enables you to specify the exact location of its children.
Other Layouts
Normal way, just display text in GridView layout
GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.
Grid View
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.
RelativeLayout lets child views specify their position relative to the parent view or to each other (specified by ID). So you can align two elements by right border, or make one below another, centered in the screen, centered left, and so on.
Positioning Views
Destroyed
Stopped
Paused
Active or Running
Four states of an Activity
Activities in the system are managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity
Then simply call setAdapter() on your ListView
ArrayAdapter
You can populate an AdapterView such as ListView or GridView by binding the AdapterView instance to an Adapter, which retrieves data from an external source and creates a View that represents each data entry.
Filling an adapter view with data
The arguments for this constructor are:
Your app Context
The layout that contains a TextViewfor each string in the array
The string array
Same way you can also apply theme to specific Activity using the same tag but for activity tag in manifest xml file.
Creating a Custom Theme
All of the attributes related to style have been removed from the layout XML and put into a style definition called CodeFont, which is then applied with the style attribute. CodeFont is defined below.
A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.

Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
Styles & Themes
Another example:
And turn it into this:
For example, by using a style, you can take this layout XML:
Handling menu item selection in Context Menu
Handling click events
In the Android SDK, you don’t need to create a menu object from scratch. Because an activity is associated with a single menu, Android creates this single menu for that activity and passes it to the onCreateOptionsMenu() callback method of the activity class
Menu
Inflating XML Menu Resource Files
Adding Menu items at runtime
Defining a Menu in XML
Same way there exists android:enabled="true", android:alphabeticShortcut="a", android:visible="true".
Menu icon tag
You can use the checked tag to control checkable behavior at an item level
In an XML file, you can specify the category of a group by using the menuCategory tag:
XML Menu Tags
Context Menus
Big picture style
The details area contains a bitmap up to 256 dp tall in its detail section.
Big text style
Displays a large text block in the details section.
Inbox style
Displays lines of text in the details section.
 
All of the big view styles also have the following content options that aren't available in normal view:
Big content title
Allows you to override the normal view's content title with a title that appears only in the expanded view.
Summary text
Allows you to add a line of text below the details area.
Creating a Notification
Notice that the big view shares most of its visual elements with the normal view. The only difference is callout number 7, the details area. Each big view style sets this area in a different way. The available styles are:
Big view
Notifications in the notification drawer
A custom dialog layout : res/layout/dialog_signin.xml
First, retrieve the LayoutInflater with getLayoutInflater() (or getSystemService()), and then inflate the layout from XML using inflate(int, ViewGroup).
For example, here's the layout file for the dialog in Figure below
If you want a custom layout in a dialog, create a layout and add it to an AlertDialog by calling setView() on your AlertDialog.Builder object.
 
By default, the custom layout fills the dialog window, but you can still use AlertDialog.Builder methods to add buttons and a title.
Creating a Custom Layout
Adding a list
The AlertDialog class allows you to build a variety of dialog designs and is often the only dialog class you'll need.
Building an Alert Dialog
AlertDialog
A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
 
DatePickerDialog or TimePickerDialog
A dialog with a pre-defined UI that allows the user to select a date or time.
 
Avoid ProgressDialog:
Android includes another dialog class called ProgressDialog that shows a dialog with a progress bar.
The Dialog class is the base class for dialogs, but you should avoid instantiating Dialog directly. Instead, use one of the following subclasses:
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.
Android Dialogs
To create a custom layout, define a View layout, in XML or in your application code, and pass the root View object to the setView(View) method.
Creating a Custom Toast View
You can simplify this to one line as follows
Positioning your Toast
“A toast provides simple feedback about an operation in a small popup”.
Toasts
A notification is a message you can display to the user outside of your application's normal UI. When you tell the system to issue a notification, it first appears as an icon in the notification area. To see the details of the notification, the user opens the notification drawer. Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.
Notifications
The system also dismisses the dialog when the user touches an item in a dialog list, except when the list uses radio buttons or checkboxes. Otherwise, you can manually dismiss your dialog by calling dismiss() on your DialogFragment.
When the user touches any of the action buttons created with an AlertDialog.Builder, the system dismisses the dialog for you.
Dismissing a Dialog
Showing a Dialog
To add action buttons call the setPositiveButton() and setNegativeButton() methods
Adding buttons
Now, when you create an instance of this class and call show() on that object, the dialog appears
Creating a Dialog Fragment
This example demonstrates everything you need for most toast notifications. You should rarely need anything else.
First, instantiate a Toast object with one of the makeText() methods. This method takes three parameters: the application Context, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with show(), as shown in the following example:
The Basics
The callouts in the illustration refer to the following:
1. Content title, 2. Large icon, 3. Content text, 4. Content info, 5. Small icon, 6. Time that the notification was issued. You can set an explicit value with setWhen(); if you don't it defaults to the time that the system received the notification.
Normal view
Notification Display Elements
Three Different ways of storing data are:
Shared Preferences
File System
Database
You can use file to store your data.
Two way storing the data to file
--> Internal Storage
--> External Storage(Inside sdcard).
Persisting the data to the Files
--> once you got the reference to the SharedPreferences.Editor object
call following methods to put the data into the auto-generated .xml file
under the directory(open DDMS perspective)
data/data/<package_name>/shared_prefs folder
➤putString(): putting String type values into the xml file
➤ putBoolean()
➤ putLong()
➤ putInt()
➤ putFloat()
Continued...
--> We are achieving Shared Preference concept by using 2 interfaces.
-->android.content.SharedPreferences
-->android.content.SharedPreferences.Editor
--> Calling getSharedPreferences() on Activity class gives you SharedPreferences object.
--> On SharedPreferences object call a method called edit(), which will give you the reference to the SharedPreferences.Editor interface.
Continued...
--> This is used to store small chunk of data.
--> Android provides the SharedPreferences help you save simple application data.
--> It stores the data in the form of key value pair inside xml file.
--> For example, your application may have an option to allow users to specify the font size of the text displayed in your application. In this case, your application needs to remember the size set by the user so that the next time he or she uses the application again, your application can set the size appropriately.
Shared Preferences
Data Persistence/Storing the Data locally
// To upgrade the database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS contacts");
onCreate(db);
}
}
--> On the MyDatabaseHelper class instance call these methods...
// ---opens the database---
MyDatabaseHelper.getWritableDatabase();
// ---closes the database---
MyDatabaseHelper.close();
Continued...
MyDatabaseHelper .java
private static class MyDatabaseHelper extends SQLiteOpenHelper {
MyDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// To create table in the database.
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(SQL_statement_to_create_DATABASE);
} catch (SQLException e) {
e.printStackTrace();
}
Sample Example
--> To create a database for our Android App, use the Android API's packages like android.database.sqlite

import android.database.sqlite.SQLiteOpenHelper
--> By using this class instance object create, open, close and upgrade the database.
import android.database.sqlite.SQLiteDatabase
--> By using this class instance object and its properties, send the SQL statements to the database to create database and to perform CRUD operation
C-Create(insert), R-Retrieve, U-Update, D-Delete
Continued...
--> If you have data that can be represented using key/value pairs, then use the SharedPreferences object.
Ex: if you want to store user preference data such as user name, background color, date of birth, last login date, then the SharedPreferences object is the ideal way to store these data.
--> If you need to store ad-hoc data, then using the internal storage is a good option.
Ex: your application (such as an RSS reader) may need to download images from the Web for display.
Ex: You may also need to persist data created by the user, such as when you have a note-taking application where users can take notes and save them for later use.
--> There are times when you need to share your application data with other users then using the internal storage is a good option.
Choosing the Best Storage Option
How it works
--> Sometimes, it would be useful to save files to external storage (such as an SD card) because of its larger capacity, as well as the capability to share the files easily with other users (by removing the SD card and passing it to somebody else).
--> To save a file into a external storage or SD Card , first thing is to get the absolute path to SD Card.
--> To store data into the SC Card, there is a class called android.os.Environment which gives the values of environment variables of android.
Saving to External Storage
--> To convert a character stream into a byte stream, you use an instance of the OutputStreamWriter class, by passing it an instance of the FileOutputStream object:
OutputStreamWriter osw = new OutputStreamWriter(fOut);
--> You then use its write() method to write the string to the file. To ensure that all the bytes are written to the file, use the flush() method. Finally, use the close() method to close the file:
osw.write(text);
osw.flush();
osw.close();
Continued...
--> Here is sample code:
// -- get the shared preferences object --
SharedPreferences prefs = getSharedPreferences(prefName, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
// -- save the values in the EditText view to preferences --
float size = editText.getTextSize();
editor.putFloat(FONT_SIZE_KEY, size);
editor.putString(TEXT_VALUE_KEY, editText.getText().toString());
// -- saves the value in preferences --
editor.commit();
Continued...
adb shell
cd data/data
cd <pkg_name>databses
ls
sqlite3 MyDB “select * from contacts”
Commands to access Database
Database is used to store data.

Android uses SQLite Database to store Relational Data.
The database what you create in an application is only accessible to itself. Other applications cannot access it.

Why database?
→ For example, if you want to store the results of all the students in a school, it is much more efficient to use a database to represent them because you can use database querying to retrieve the results of the specific students.
CREATING AND USING DATABASES
--> A method called getExternalStorageDirectory() returns the full path to the external storage. Typically, it should return the “/sdcard” path for a real device, and “/mnt/sdcard” for an Android Emulator.

--> However, you should never try to hard code the path to the SD card, as manufacturers may choose to assign a different path name to the SD card. Hence, be sure to use the getExternalStorageDirectory() method to return the full path to the SD card. You then create a directory called MyFiles in the SD card. Finally, you save the file into this directory.

--> Note: in order to write to the external storage, you need to add the WRITE_EXTERNAL_STORAGE permission in your AndroidManifest.xml file.
Continued...
-->To read the content of a file, you use the FileInputStream class, together with the InputStreamReader class:
FileInputStream fIn = openFileInput(“textfile.txt”);
InputStreamReader isr = new InputStreamReader(fIn);

--> When testing this application on the Android Emulator, you can use the DDMS to verify that the application did indeed save the file into the application’s files directory, the actual directory is
/data/data/<package_name>/files
Continued...
How it works
--> To save text into a file, you use the FileOutputStream class. The openFileOutput() method opens a named file for writing, with the mode specified.
Ex: FileOutputStream fOut = openFileOutput(“textfile.txt”, MODE_WORLD_READABLE);
--> MODE_WORLD_READABLE (constant to indicate that the file is readable by all other applications)
MODE_PRIVATE (file can only be accessed by the application that created it)
MODE_APPEND (for appending to an existing file) and
MODE_WORLD_WRITEABLE (all other applications have write access to the file).
Saving to Internal Storage
3. Design ContentProvider URI:
→ A content URI is a URI that identifies data in a provider.
→ Content URIs include the symbolic name of the entire provider (its authority) and a name that points to a table or file (a path).
→ The optional id part points to an individual row in a table.
→ Every data access method of ContentProvider has a content URI as an argument; this allows you to determine the table, row, or file to access.
Continued...
→ In Android's vendor-specific MIME format:
I. Type part: vnd
II. Subtype part:
If the URI pattern is for a single row: android.cursor.item/
If the URI pattern is for more than one row: android.cursor.dir/
III. Provider-specific part: vnd.<name>.<type>
<name> – com.example.provider
<type> – specific table name
→ the MIME type for multiple rows in table1 is:
vnd.android.cursor.dir/vnd.com.example.provider.table1

→ For a single row of table1, the MIME type is:
vnd.android.cursor.item/vnd.com.example.provider.table1
Continued...
Before creating CP class, create a DB for your App.
Steps to Create a CP in your App.
1. Create a User defined ContentProvider class by extending android.content.ContentProvider class.
→ Give implementation to the following methods.
a. onCreate(): Initialize your provider.
b. getType(): Return the MIME type corresponding to a content URI.
→ For content URIs that point to a row or rows of table data, getType() should return a MIME type.
Creating a Content Provider
By using the “ android.content.* ” package we can access the already biultIn ContentProvider App like contacts, images, audio, video, calender … so on

In order to get access to the ContentProvider, first we should know the URI of it. And by using ContentResolver class object as a client which is going to communicate with the ContentProvider.

Now, CP gets access to the DB based on the incoming query operation from the CR object. And returns data from DB to CR.

NOTE: To access a provider, your application usually has to request specific permissions in its Androidmanifest file.
Consuming BuiltIn ContentProvider
The ContentResolver(CR) object in the client application's process and the ContentProvider object in the application that owns the provider automatically handle inter-process communication.
ContentProvider(CP) also acts as an abstraction layer between its repository of data and the external appearance of data as tables.
ContentProvider:
→Consuming BuiltIn ContentProvider
→Custom/Own ContentProvider
Continued...
An application accesses the data from a content provider with a ContentResolver client object.
→ android.content.ContentResolver
→ public abstract class ContentResolver extends Object

This object has methods that call identically-named methods in the provider object, an instance of one of the concrete subclasses of ContentProvider.

The ContentResolver methods provide the basic "CRUD" (create, retrieve, update, and delete) functions of persistent storage.
Accessing a provider
A ContentProvider can be used internally in an application to access data. If the data should be shared with another application a ContentProvider allows this.
→ android.content.ContentProvider
→ public abstract class ContentProvider extends Object
The access to a ContentProvider is done via an URI. The basis for the URI is defined in the declaration of the ContentProvider in the AndroidManifest.xml file via the android:authorities attribute.
Many Android datasources, e.g. the contacts, are accessible via ContentProviders. Typically the implementing classes for a ContentProviders provide public constants for the URIs.
Continued...
An SQLite database is private to the application which creates it. If you want to share data with other applications you can use a ContentProvider.

Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security.

Content providers are the standard interface that connects data in one process with code running in another process.

A ContentProvider allows applications to access data. In most cases this data is stored in an SQlite database.
Content Providers
Content Providers in Android
* Designing an authority:
→ if your Android package name is com.example.<appname>, you should give your provider the authority com.example.<appname>.provider.
* Designing a path structure:
→ you combine the authority from the previous example to yield the content URIs com.example.<appname>.provider/table1 and com.example.<appname>.provider/table2.
* The content URI pattern:
content://<authority>/<path> for tables, and content://<authority>/<path>/<id> for single rows.
Continued...
c. insert(): Insert a new row into your provider.
d. query(): Retrieve data from your provider.
e. update(): Update existing rows in your provider.
f. delete(): Delete rows from your provider

2. Register this CP class in AndroidManifest.xml file.

<application ….

<provider android:name= “<pkg_name>.<CP class name>”
andriod:authorities= “com.example.provider”

</provider>

</application>
Continued...
An Activity or Service can initiate a status notification.
The process of sending a notification has the following three steps:
1. Create a suitable notification.
2. Get access to the notification manager.
3. Send the notification to the notification manager.
When you create a notification, you’ll need to ensure that it had the following basic parts:
→ An icon to display
→ Ticker text like “hello world”
→ The time when it is delivered
Continued...
The class BroadcastReceiver defines the onReceive() method. Only during this method your BroadcastReceiver object will be valid, afterwards the Android system can recycle the BroadcastReceiver. Therefore you cannot perform any asynchronous operation in the onReceive() method.
Continued...
Statically via AndroidManifest.xml
<reciever android:name= “<pkg_name>.BroadcastReciever classname
</reciever>
Dynamically via Context.registerReceiver()
This class will be able to receive Broadcast Intents from Activity or Services.
Broadcast Intents can be generated via the Context.sendBroadcast() method.
By calling getBroadcast() method on PendingIntent class, we can get notification message from the reciever.
Continued...
Once you have a notification object constructed with these details, you get the notification manager by asking the context to give you a system service named Context.NOTIFICATION_SERVICE.
Once you have the notification manager reference object, call the notify() method on the notification manager reference object to send the desired notification.
By using AlarmManager class we can notifiy a Broadcast intent objects at appropriate time.
Continued...
In Android app, we are dealing with notification concept by following ways...
→ By using NotificationManager and Notification.Builder class
→ By using Toast class.
→ By using Dilog class.

Android device having one feature notification bar or area at top of the device.

The notification area is also called as the status bar.

Creating a notification by using the class Notification.Builder.

Monitoring All Notifications through the class NotificationManager.
--Using Notifications from a Receiver--
A BroadcastReceiver is a piece of code to which an app subscribes in order to get notified when an action happens. That action is in a form of an intent broadcast. When the right intent is fired, the receiver wakes up and executes.

As the name indicates, a broadcast receiver is a component that can respond to a broadcast message sent by a client.

A broadcast receiver is a class which extends BroadcastReceiver and which is registered as a receiver in an Android Application via the AndroidManifest.xml file(or via code).
---Broadcast receiver---
Broadcast Receiver in Android
GeoPoint: longitude/latitude stored as integer in microdegrees (degrees * 1E6)
Overlay: Base class representing an overlay which may be displayed on top of a map
OverlayItem: The basic component of any ItemizedOverlay.
ItemizedOverlay: A base class for an Overlay which consists of a list of OverlayItems
Location Sources

LocationManager & Location Providers

Criteria

LocationListener

locationManager.requestLocationUpdates(bestProvider, time, distance , locationListener);
Find Location
Generate Certificate
keytool -genkey -v -keystore droid_kids.keystore -alias droid_kids -keyalg RSA -keysize 2048 -validity 10000

Get Fingerprint of the certificate
keytool -list -alias droid_kids -keystore droid_kids.keystore
Fingerprint is : E0:9D:58:9F:B2:CD:5C:9C:42:8B:60:0F:23:BC:24:11

Register the fingerprint with Google Maps Service
http://code.google.com/android/maps-api-signup.html
Key is: 0zu3JWra9vK5LxswGR1V4Wh3SztudX-UjgLWLJA
MapView: Obtaining Maps Key
MapActivity: Base class with code to manage the boring necessities of any activity that displays a MapView
MapView: A View which displays a map (with data obtained from the Google Maps service).
MapController: A utility class to manage panning and zooming of a map.
MyLocationOverlay: An Overlay for drawing the user's current location (and accuracy) on the map, and/or a compass-rose inset.
Google APIs 

Location Based Applications

- http://developer.android.com/guide/topics/location/index.html

- http://code.google.com/android/add-ons/google-apis/

- http://www.anddev.org/index.php

- http://itouchmap.com/latlong.html [For finding location coordinates].
References
Include Maps library
<uses-library android:name="com.google.android.maps" />

Add permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Create a MapView layout and add the key
<com.google.android.maps.MapView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/mapview"    
                android:layout_width="fill_parent"    android:layout_height="fill_parent"
                android:clickable="true"    
                android:apiKey="0zu3JWra9vK5LxswGR1V4Wh3SztudX-UjgLWLJA"/>
MapView: Create Maps Activity
All you need. [not really]
http://code.google.com/android/add-ons/google-apis/index.html
MapView: Adding Google APIs
Adding Google APIs

Obtaining Maps Key

Using MapActivity

Showing current location

Adding Overlay items
MapView
Google Maps is an external library to the Android SDK.
Layers

Zoom

Center

Overlays

MyLocation
MapView Coding
Full transcript