Click here to load reader
View
11.978
Download
8
Tags:
Embed Size (px)
DESCRIPTION
Android SDK introduction
Android SDK library distribution according to functionality
Activity, Services and Broadcast RecieversView and related classes, ListIntents, Adapters, AlertDialouge, Notifications.SharedPreferencesContentProviders and DatabasesMaps, GeocodingWidget MultimediaTelephony and SMSBluetooth and WiFiSensorsActivity, Services and Broadcast
Receivers
Activities The entry class into Android application, responsible for loading the first screen and take user inputs
-onCreate()
-onDestroy();
-onPause();
-onStart();
Services The class used to create programs that run in background, and have no UI
Broadcast receiver The android component responsible to receive responses from system wide processes and send the event notification to the registered processes
Views
View Responsible for the UI in the application.
A view is put on a layout and then as per programming directives a layout is laid
Intents, Adapters, AlertDialogue and Notifications
Intents - Intents are used as a message-passing mechanism that works both within application, and between applications. Intents can be used to:
Start an Activity or service Broadcast an event Explicitly start an ActivityAdapters - Adapters are bridging classes that bind data to Views used in the user interface. And load dynamic data in the UI
AlertDialouge To show the user the Alert and seek any response, and then perform any action on it
Notification - notify the user on any
event in the notification bar
.
Content Providers and Data storage
Content Providers - Content providers are interfaces to store and retrieve data and make it accessible to all applications. They're the only way to share data across applications
Data Storage - Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs
Shared Preferences Store private primitive data in key-value pairs. Internal Storage Store private data on the device memory. External Storage Store public data on the shared external storage. SQLite Databases Store structured data in a private database. Network Connection Store data on the web with your own network server.Data storage methods in brief
Shared preferences - The SharedPreferences class provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types
getSharedPreferences(), getPreferences() use these methods to obtain multiple or single preferences for the application respectively.
Edit() or putBoolean(), putString() etc use the former method to use SharedPreference.Editor, and later methods to directly specify and enter the data
Internal Storage - We can save files directly on the device's internal storage, by using the FileStream class and its methods write() and read() etc.
External Storage The external storage device in Android mobiles is the SD card. We can save and retrieve data on SD card using some of the methods
getExternalStorageState() to check the availability and status of SD cardgetExternalStorageDirectory() to open the file which represent the root of the external storage file system.SQLite Database
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.
To create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method, in which you can execute a SQLite command to create tables in the database.
getWritableDatabase() and getReadableDatabase()
To write and read from database, their return type is SQLiteDatabase class that provides methods for database operations.
SQLiteDatabase query() methods to execute queries, these methods takes various parameters, for various quires.
Cursor Its the return type of any SQLite query and the mechanism with which you can navigate results from a database query and read rows and columns.
Maps and GeoCoding
Important classes related to GPS capabilities in Android
LocationManager - This class provides access to the system location services. These services allow applications to obtain periodic updates of the device's geographical location.getLastKnownLocation(provider);
Proximity alert settingGeocoding - Geocoding is the process of transforming a street address or other description of a location into a (latitude, longitude) coordinate. Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a (partial) address.Geocoder(Contextcontext,Localelocale)
Geocoder(Contextcontext)
Android App Widgets
App Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic updates.
AppWidgetProviderInfo object Describes the metadata for an App Widget.
AppWidgetProvider class implementation Defines the basic methods that allow you to programmatically interface with the App Widget, based on broadcast events.
onUpdate()
onDeleted(Context, int[])
onEnabled(Context)
onReceive(Context, Intent)
View class to draw the widget layout
Multimedia content
Multimedia playback in Android is handled by the MediaPlayer class. You can play media stored in application resources, local files, Content Providers, or streamed from a network URL
create(appContext, R.raw.my_audio);
setDataSource("/sdcard/test2.3gp");
prepare();
For playing Video, we have to use a VideoView to act a surface to display the video
MediaRecorder class and associated methods are used for recording video
Using Intents Actions we can use camera and audio recording features
Telephony and SMS
Provides APIs for monitoring the basic phone information, such as the network type and connection state, plus utilities for manipulating phone number strings.
CellLocation, NeighboringCellInfo PhoneNumberUtilsPhoneStateListenerServiceState. SignalStrength. TelephonyManagerSmsManager - Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method SmsManager.getDefault()
sendTextMessage() to send text SMS
Bluetooth and WiFi
Using the Bluetooth APIs, an Android application can perform the following:
Scan for other Bluetooth devicesQuery the local Bluetooth adapter for paired Bluetooth devicesConnect to other devices through service discoveryTransfer data to and from other devicesManage multiple connectionsBluetoothAdapter - The BluetoothAdapter is the entry-point for all Bluetooth interaction.
BluetoothDevice - Represents a remote Bluetooth device.
BluetoothSocket - This is the connection point that allows an application to exchange data with another Bluetooth device via InputStream and OutputStream.
BluetoothServerSocket - - Represents an open server socket that listens for incoming requests (similar to a TCP ServerSocket).
The WifiManager represents the Android Wi-Fi Connectivity Service. It can be used to configure Wi-Fi network connections, manage the current Wi-Fi connection, scan for access points, and monitor changes in Wi-Fi connectivity
Android Booting Sequence
Stages In Booting of Android OS from power on
Stage 1 : Power on and boot ROM code execution
Stage 2: The boot loader loading
Stage 3: Starting of Linux kernel
Stage 4: The init process
Stage 5: Zygote and Dalvik
Stage 6: The system server initiation
Android Booting Sequence Stage 1
Power on and boot ROM code execution
At power on the CPU will be in a state where no initializations have been done. Internal clocks are not set up and the only memory available is the internal RAM. When power supplies are stable the execution will start with the Boot ROM code. The Boot ROM code will detect the boot media using a system register that maps to some physical balls on the ASIC. This is to determine where to find the first stage of the boot loader. Once the boot media sequence is established the boot ROM will try to load the first stage boot loader to internal RAM. Once the boot loader is in place the boot ROM code will perform a jump and execution continues in the boot loader.Android Booting Sequence Stage 2
The boot loader loading
The first boot loader stage will detect and set up external RAM. Once external RAM is available and the system is ready the to run something more significant the first stage will load the main boot loader and place it in external RAM. The second stage of the boot loader is the first major program that will run. This may contain code to set up file systems, additional memory, network support, loading code for the modem CPU and setting up low level memory protections and security options. Once the boot loader is done with any special tasks it will look for a Linux kernel to boot. It will load this from the boot media (or some other source depending on system configuration) and place it in the RAM. Once the boot loader is done it will perform a jump to the Linux kernel, usually some decompression routine, and the kernel assumes system responsibilityAndroid Booting Sequence Stage 3
Starting of Linux kernel
It will set up everything that is needed for the system to run. Initialize interrupt controllers, set up memory protections, caches and scheduling.
Once the memory management units and caches have been initialized the system will be able to use virtual memory and launch user space processes. The kernel will