News:
- In an internet driven environment, it is imperative for a company to keep its product or business to the forefront of potential customers' minds. The ...
- A successful enterprise is all about constantly reinventing ways to work more efficiently. In today’s techno age, this translates to testing new too...
- The IT industry plays a pivotal role in providing application development solutions and custom software development to a wide range of industries, i...
- Royal Victorian Eye and Ear Hospital, 2010 Atcomm has been contracted to implement a complex IOP glaucoma management tool which will be distribut...
- We are pleased to announce another implementation of a CMS system for a large Melbourne based fitness center - Star Plate Studio. Atcomm has depl...
Friday, 16 July 2010 16:42
Android Service Components
-
font size
decrease font size
increase font size
Security is a fundamental part of the Android Platform. In Android, security spans all phases of the application lifecycle—from design-time policy considerations to runtime boundary checks. Location-based service is another one of the more exciting pieces of the Android SDK.This portion of the SDK provides application developers APIs to display and manipulate maps,as well as obtain real-time device-location information. We’ll cover these ideas in detail in Chapter 7.
In Chapter 8, we’ll show you how to build and consume services in Android, specifically HTTP services. The chapter will also cover interprocess communication (communication between applications on the same device). Here is an example of doing an HttpPost in Android:
InputStream is = this.getAssets().open("data.xml");
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://192.178.10.131/WS2/Upload.aspx");
byte[] data = IOUtils.toByteArray(is);
InputStreamBody isb = new InputStreamBody(
new ByteArrayInputStream(data),"uploadedFile");
StringBody sb1 = new StringBody("someTextGoesHere");
StringBody sb2 = new StringBody("someTextGoesHere too");
MultipartEntity multipartContent = new MultipartEntity();
multipartContent.addPart("uploadedFile", isb);
multipartContent.addPart("one", sb1);
multipartContent.addPart("two", sb2);
postRequest.setEntity(multipartContent);
HttpResponse res =httpClient.execute(postRequest);
res.getEntity().getContent().close();
Android Media and Telephony Components
Android has APIs that cover audio, video, and telephony components. Here is a quick example
of how to play an audio file from an Internet URL:
private void playAudio(String url)throws Exception
{
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(internetUrl);
mediaPlayer.prepare();
mediaPlayer.start();
}
And here’s an example of playing an audio file from the local device:
private void playLocalAudio()throws Exception
{
//The file is located in the /res/raw directory and called "music_file.mp3"
mediaPlayer = MediaPlayer.create(this, R.raw.music_file);
mediaPlayer.start();
}
We’ll cover these audio and video APIs extensively in Chapter 9. The chapter will also
address the following aspects of the telephony API:
• Sending and receiving Short Message Service (SMS) messages
• Monitoring SMS messages
• Managing SMS folders
• Placing and receiving phone calls
Here is an example taken from that chapter on sending an SMS message:
private void sendSmsMessage(String address,String message)throws Exception
{
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(address, null, message, null, null);
}
Prior to the 1.5 release you could record audio but not video. Both audio and video recording are accommodated in 1.5 through MediaRecorder. This is covered with examples in Chapter 12. Chapter 12 also covers voice recognition, along with the input-method framework (IMF), which allows a variety of inputs to be interpreted as text while typing into text controls.The input methods include keyboard, voice, pen device, mouse, etc. This framework was origi-nally designed as part of Java API 1.4; you can read more about it at the following Java site:
http://java.sun.com/j2se/1.4.2/docs/guide/imf/overview.html
Last but not least, Android ties all these concepts into an application by creating a single XML file that defines what an application package is. This file is called the application’s mani-fest file (AndroidManifest.xml). Here is an example:
package="com.ai.android.HelloWorld"
android:versionCode="1"
android:versionName="1.0.0">
android:label="@string/app_name">
The Android manifest file is where activities are defined, where services and content pro-viders are registered, and where permissions are declared. Details about the manifest file will emerge throughout the book as we develop each idea.
Android Java Packages
One way to get a quick snapshot of the Android Platform is to look at the structure of Java packages. Because Android deviates from the standard JDK distribution, it is important to know at a high level what is supported and what is not. Here’s a brief description of the impor-tant Java packages that are included in the Android SDK:
• android.app: Implements the Application model for Android. Primary classes include Application, representing the start and stop semantics, as well as a number of activity-related classes, controls, dialogs, alerts, and notifications.
• android.appwidget: Implements the mechanism for allowing applications to publish their views in other applications, such as the home page. The primary classes include AppWidgetHost, AppWidgetHostView, AppWidgetManager, AppWidgetProvider, and AppWidgetProviderInfo. This package is available only in SDK 1.5.
• android.content: Implements the concepts of content providers. Content providers abstract out data access from data stores. This package also implements the central ideas around intents and Android Uniform Resource Identifiers (URIs).
• android.content.pm: Implements Package Manager–related classes. A package man-ager knows about permissions, installed packages, installed providers, installed services, installed components such as activities, and installed applications.
• android.content.res: Provides access to resource files both structured and unstructured.The primary classes are AssetManager (for unstructured resources) and Resources.
• android.database: Implements the idea of an abstract database. The primary interface is the Cursor interface.
• android.database.sqlite: Implements the concepts from the android.database package using SQLite as the physical database. Primary classes are SQLiteCursor, SQLiteDatabase, SQLiteQuery, SQLiteQueryBuilder, and SQLiteStatement. However, most of your inter-action is going to be with classes from the abstract android.database package.
• android.graphics: Contains the classes Bitmap, Canvas, Camera, Color, Matrix, Movie,Paint, Path, Rasterizer, Shader, SweepGradient, and TypeFace.
• android.graphics.drawable: Implements drawing protocols and background images, and allows animation of drawable objects.
• android.graphics.drawable.shapes: Implements shapes including ArcShape, OvalShape, PathShape, RectShape, and RoundRectShape.
• android.hardware: Implements the physical Camera-related classes. This Camera repre-sents the hardware camera, whereas android.graphics.Camera represents a graphical concept that’s not related to a physical camera at all.
•android.inputmethodservice: Implements the interfaces and base abstract classes nec-essary for writing input methods.
•android.location: Contains the classes Address, GeoCoder, Location, LocationManager, and LocationProvider. The Address class represents the simplified XAL (Extensible Address Language). GeoCoder allows you to get a latitude/longitude coordinate given an address, and vice versa. Location represents the latitude/longitude.
•android.media: Contains the classes MediaPlayer, MediaRecorder, Ringtone, AudioManager, and FaceDetector. MediaPlayer, which supports streaming, is used to play audio and video. MediaRecorder is used to record audio and video. The Ringtone class is used to play short sound snippets that could serve as ringtones and notifica-
tions. AudioManager is responsible for volume controls. You can use FaceDetector to detect people’s faces in a bitmap.
•android.net: Implements the basic socket-level network APIs. Primary classes include Uri, ConnectivityManager, LocalSocket, and LocalServerSocket.
•android.net.wifi: Manages WiFi connectivity. Primary classes include WifiManager and WifiConfiguration. WifiManager is responsible for listing the configured networks and the currently active WiFi network.
•android.opengl: Contains utility classes surrounding OpenGL ES operations. The pri-mary classes of OpenGL ES are implemented in a different set of packages borrowed from JSR 239. These packages are javax.microedition.khronos.opengles, javax. microedition.khronos.egl, and javax.microedition.khronos.nio. These packages are thin wrappers around the Khronos implementation of OpenGL ES in C and C++.
•android.os: Represents the OS services accessible through the Java programming lan-guage. Some important classes include BatteryManager, Binder, FileObserver, Handler, Looper, and PowerManager. Binder is a class that allows interprocess communication. FileObserver keeps tabs on changes to files. You use Handler classes to run tasks on the
message thread, and Looper to run a message thread.
•android.preference: Allows applications the ability to have users manage their preferences for that application in a uniform way. The primary classes are PreferenceActivity, PreferenceScreen, and various Preference-derived classes
such as CheckBoxPreference and SharedPreferences.
•android.provider: Comprises a set of prebuilt content providers adhering to the android.content.ContentProvider interface. The content providers include Contacts, MediaStore, Browser, and Settings. This set of interfaces and classes stores the meta-data for the underlying data structures.
•android.sax: Contains an efficient set of Simple API for XML (SAX) parsing utility classes. Primary classes include Element, RootElement, and a number of ElementListener interfaces.
•android.speech: Contains constants for use with speech recognition. This package is available only in releases 1.5 and later.
•android.telephony: Contains the classes CellLocation, PhoneNumberUtils, and TelephonyManager. A TelephonyManager lets you determine cell location, phone number, network-operator name, network type, phone type, and Subscriber Identity Module (SIM) serial number.
•android.telephony.gsm: Allows you to gather cell location based on cell towers and also hosts classes responsible for SMS messaging. This package is called GSM because Global System for Mobile Communication is the technology that originally defined the SMS data-messaging standard.
•android.text: Contains text-processing classes.
•android.text.method: Provides classes for entering text input for a variety of controls.
•android.text.style: Provides a number of styling mechanisms for a span of text.
•android.utils: Contains the classes Log, DebugUtils, TimeUtils, and Xml.
•android.view: Contains the classes Menu, View, ViewGroup, and a series of listeners and callbacks.
•android.view.animation: Provides support for tweening animation. The main classes include Animation, a series of interpolators for animation, and a set of specific animator classes that include AlphaAnimation, ScaleAnimation, TranslationAnimation, and RotationAnimation.
•android.view.inputmethod: Implements the input-method framework architecture. This package is available only in releases 1.5 and later.
•android.webkit: Contains classes representing the web browser. The primary classes include WebView, CacheManager, and CookieManager.
•android.widget: Contains all of the UI controls usually derived from the View class. Primary widgets include Button, Checkbox, Chronometer, AnalogClock, DatePicker, DigitalClock, EditText, ListView, FrameLayout, GridView, ImageButton, MediaController, ProgressBar, RadioButton, RadioGroup, RatingButton, Scroller, ScrollView, Spinner,
TabWidget, TextView, TimePicker, VideoView, and ZoomButton.
•com.google.android.maps: Contains the classes MapView, MapController, and MapActivity, essentially classes required to work with Google maps.
These are some of the critical Android-specific packages. From this list you can see the depth of the Android core platform.
Note In all, the Android Java API contains more than 36 packages and more than 700 classes.
In addition, Android provides a number of packages in the java.* namespace. These include awt.font, io, lang, lang.annotation, lang.ref, lang.reflect, math, net, nio, nio.channels, nio.channels.spi, nio.charset, security, security.acl, security.cert, security.interfaces, security.spec, sql, text, util, util.concurrent, util.concurrent. atomic, util.concurrent.locks, util.jar, util.logging, util.prefs, util.regex, and util.zip.
Android comes with these packages from the javax namespace: crypto, crypto.spec, microedition.khronos.egl, microedition.khronos.opengles, net, net.ssl, security.auth, security.auth.callback, security.auth.login,security.auth.x500, security.cert, sql, xml, and xmlparsers.
In addition, it contains a lot of packages from org.apache.http.*. It also carries org.json, org.w3c.dom, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, org.xmlpull.v1, and org. xmlpull.v1.sax2.
Together, these numerous packages provide a rich computing platform to write applica-tions for handheld devices.
Taking Advantage of Android Source Code
During these early releases of Android, documentation is a bit “wanting” in places. When you run into that situation, it is worthwhile exploring Android source code to fill the gaps.
In Chapter 8, we’ll show you how to build and consume services in Android, specifically HTTP services. The chapter will also cover interprocess communication (communication between applications on the same device). Here is an example of doing an HttpPost in Android:
InputStream is = this.getAssets().open("data.xml");
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://192.178.10.131/WS2/Upload.aspx");
byte[] data = IOUtils.toByteArray(is);
InputStreamBody isb = new InputStreamBody(
new ByteArrayInputStream(data),"uploadedFile");
StringBody sb1 = new StringBody("someTextGoesHere");
StringBody sb2 = new StringBody("someTextGoesHere too");
MultipartEntity multipartContent = new MultipartEntity();
multipartContent.addPart("uploadedFile", isb);
multipartContent.addPart("one", sb1);
multipartContent.addPart("two", sb2);
postRequest.setEntity(multipartContent);
HttpResponse res =httpClient.execute(postRequest);
res.getEntity().getContent().close();
Android Media and Telephony Components
Android has APIs that cover audio, video, and telephony components. Here is a quick example
of how to play an audio file from an Internet URL:
private void playAudio(String url)throws Exception
{
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(internetUrl);
mediaPlayer.prepare();
mediaPlayer.start();
}
And here’s an example of playing an audio file from the local device:
private void playLocalAudio()throws Exception
{
//The file is located in the /res/raw directory and called "music_file.mp3"
mediaPlayer = MediaPlayer.create(this, R.raw.music_file);
mediaPlayer.start();
}
We’ll cover these audio and video APIs extensively in Chapter 9. The chapter will also
address the following aspects of the telephony API:
• Sending and receiving Short Message Service (SMS) messages
• Monitoring SMS messages
• Managing SMS folders
• Placing and receiving phone calls
Here is an example taken from that chapter on sending an SMS message:
private void sendSmsMessage(String address,String message)throws Exception
{
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(address, null, message, null, null);
}
Prior to the 1.5 release you could record audio but not video. Both audio and video recording are accommodated in 1.5 through MediaRecorder. This is covered with examples in Chapter 12. Chapter 12 also covers voice recognition, along with the input-method framework (IMF), which allows a variety of inputs to be interpreted as text while typing into text controls.The input methods include keyboard, voice, pen device, mouse, etc. This framework was origi-nally designed as part of Java API 1.4; you can read more about it at the following Java site:
http://java.sun.com/j2se/1.4.2/docs/guide/imf/overview.html
Last but not least, Android ties all these concepts into an application by creating a single XML file that defines what an application package is. This file is called the application’s mani-fest file (AndroidManifest.xml). Here is an example:
android:versionCode="1"
android:versionName="1.0.0">
The Android manifest file is where activities are defined, where services and content pro-viders are registered, and where permissions are declared. Details about the manifest file will emerge throughout the book as we develop each idea.
Android Java Packages
One way to get a quick snapshot of the Android Platform is to look at the structure of Java packages. Because Android deviates from the standard JDK distribution, it is important to know at a high level what is supported and what is not. Here’s a brief description of the impor-tant Java packages that are included in the Android SDK:
• android.app: Implements the Application model for Android. Primary classes include Application, representing the start and stop semantics, as well as a number of activity-related classes, controls, dialogs, alerts, and notifications.
• android.appwidget: Implements the mechanism for allowing applications to publish their views in other applications, such as the home page. The primary classes include AppWidgetHost, AppWidgetHostView, AppWidgetManager, AppWidgetProvider, and AppWidgetProviderInfo. This package is available only in SDK 1.5.
• android.content: Implements the concepts of content providers. Content providers abstract out data access from data stores. This package also implements the central ideas around intents and Android Uniform Resource Identifiers (URIs).
• android.content.pm: Implements Package Manager–related classes. A package man-ager knows about permissions, installed packages, installed providers, installed services, installed components such as activities, and installed applications.
• android.content.res: Provides access to resource files both structured and unstructured.The primary classes are AssetManager (for unstructured resources) and Resources.
• android.database: Implements the idea of an abstract database. The primary interface is the Cursor interface.
• android.database.sqlite: Implements the concepts from the android.database package using SQLite as the physical database. Primary classes are SQLiteCursor, SQLiteDatabase, SQLiteQuery, SQLiteQueryBuilder, and SQLiteStatement. However, most of your inter-action is going to be with classes from the abstract android.database package.
• android.graphics: Contains the classes Bitmap, Canvas, Camera, Color, Matrix, Movie,Paint, Path, Rasterizer, Shader, SweepGradient, and TypeFace.
• android.graphics.drawable: Implements drawing protocols and background images, and allows animation of drawable objects.
• android.graphics.drawable.shapes: Implements shapes including ArcShape, OvalShape, PathShape, RectShape, and RoundRectShape.
• android.hardware: Implements the physical Camera-related classes. This Camera repre-sents the hardware camera, whereas android.graphics.Camera represents a graphical concept that’s not related to a physical camera at all.
•android.inputmethodservice: Implements the interfaces and base abstract classes nec-essary for writing input methods.
•android.location: Contains the classes Address, GeoCoder, Location, LocationManager, and LocationProvider. The Address class represents the simplified XAL (Extensible Address Language). GeoCoder allows you to get a latitude/longitude coordinate given an address, and vice versa. Location represents the latitude/longitude.
•android.media: Contains the classes MediaPlayer, MediaRecorder, Ringtone, AudioManager, and FaceDetector. MediaPlayer, which supports streaming, is used to play audio and video. MediaRecorder is used to record audio and video. The Ringtone class is used to play short sound snippets that could serve as ringtones and notifica-
tions. AudioManager is responsible for volume controls. You can use FaceDetector to detect people’s faces in a bitmap.
•android.net: Implements the basic socket-level network APIs. Primary classes include Uri, ConnectivityManager, LocalSocket, and LocalServerSocket.
•android.net.wifi: Manages WiFi connectivity. Primary classes include WifiManager and WifiConfiguration. WifiManager is responsible for listing the configured networks and the currently active WiFi network.
•android.opengl: Contains utility classes surrounding OpenGL ES operations. The pri-mary classes of OpenGL ES are implemented in a different set of packages borrowed from JSR 239. These packages are javax.microedition.khronos.opengles, javax. microedition.khronos.egl, and javax.microedition.khronos.nio. These packages are thin wrappers around the Khronos implementation of OpenGL ES in C and C++.
•android.os: Represents the OS services accessible through the Java programming lan-guage. Some important classes include BatteryManager, Binder, FileObserver, Handler, Looper, and PowerManager. Binder is a class that allows interprocess communication. FileObserver keeps tabs on changes to files. You use Handler classes to run tasks on the
message thread, and Looper to run a message thread.
•android.preference: Allows applications the ability to have users manage their preferences for that application in a uniform way. The primary classes are PreferenceActivity, PreferenceScreen, and various Preference-derived classes
such as CheckBoxPreference and SharedPreferences.
•android.provider: Comprises a set of prebuilt content providers adhering to the android.content.ContentProvider interface. The content providers include Contacts, MediaStore, Browser, and Settings. This set of interfaces and classes stores the meta-data for the underlying data structures.
•android.sax: Contains an efficient set of Simple API for XML (SAX) parsing utility classes. Primary classes include Element, RootElement, and a number of ElementListener interfaces.
•android.speech: Contains constants for use with speech recognition. This package is available only in releases 1.5 and later.
•android.telephony: Contains the classes CellLocation, PhoneNumberUtils, and TelephonyManager. A TelephonyManager lets you determine cell location, phone number, network-operator name, network type, phone type, and Subscriber Identity Module (SIM) serial number.
•android.telephony.gsm: Allows you to gather cell location based on cell towers and also hosts classes responsible for SMS messaging. This package is called GSM because Global System for Mobile Communication is the technology that originally defined the SMS data-messaging standard.
•android.text: Contains text-processing classes.
•android.text.method: Provides classes for entering text input for a variety of controls.
•android.text.style: Provides a number of styling mechanisms for a span of text.
•android.utils: Contains the classes Log, DebugUtils, TimeUtils, and Xml.
•android.view: Contains the classes Menu, View, ViewGroup, and a series of listeners and callbacks.
•android.view.animation: Provides support for tweening animation. The main classes include Animation, a series of interpolators for animation, and a set of specific animator classes that include AlphaAnimation, ScaleAnimation, TranslationAnimation, and RotationAnimation.
•android.view.inputmethod: Implements the input-method framework architecture. This package is available only in releases 1.5 and later.
•android.webkit: Contains classes representing the web browser. The primary classes include WebView, CacheManager, and CookieManager.
•android.widget: Contains all of the UI controls usually derived from the View class. Primary widgets include Button, Checkbox, Chronometer, AnalogClock, DatePicker, DigitalClock, EditText, ListView, FrameLayout, GridView, ImageButton, MediaController, ProgressBar, RadioButton, RadioGroup, RatingButton, Scroller, ScrollView, Spinner,
TabWidget, TextView, TimePicker, VideoView, and ZoomButton.
•com.google.android.maps: Contains the classes MapView, MapController, and MapActivity, essentially classes required to work with Google maps.
These are some of the critical Android-specific packages. From this list you can see the depth of the Android core platform.
Note In all, the Android Java API contains more than 36 packages and more than 700 classes.
In addition, Android provides a number of packages in the java.* namespace. These include awt.font, io, lang, lang.annotation, lang.ref, lang.reflect, math, net, nio, nio.channels, nio.channels.spi, nio.charset, security, security.acl, security.cert, security.interfaces, security.spec, sql, text, util, util.concurrent, util.concurrent. atomic, util.concurrent.locks, util.jar, util.logging, util.prefs, util.regex, and util.zip.
Android comes with these packages from the javax namespace: crypto, crypto.spec, microedition.khronos.egl, microedition.khronos.opengles, net, net.ssl, security.auth, security.auth.callback, security.auth.login,security.auth.x500, security.cert, sql, xml, and xmlparsers.
In addition, it contains a lot of packages from org.apache.http.*. It also carries org.json, org.w3c.dom, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, org.xmlpull.v1, and org. xmlpull.v1.sax2.
Together, these numerous packages provide a rich computing platform to write applica-tions for handheld devices.
Taking Advantage of Android Source Code
During these early releases of Android, documentation is a bit “wanting” in places. When you run into that situation, it is worthwhile exploring Android source code to fill the gaps.
The details of the Android source distribution are published at http://source.android. com. The code was open sourced around October 2008 (read the announcement at http://source.android.com/posts/opensource). One of the Open Handset Alliance’s goals was to make Android a free and fully customizable mobile platform. The announcement strongly suggests that the Android Platform is a fully capable mobile computing platform with no gaps.The open source model allows contributions from noncore team members within the public communities.
As indicated, Android is a platform and not just one project. You can see the scope and the number of projects at http://source.android.com/projects.
The source code of Android and all its projects is managed by the Git source-code control system. Git (http://git.or.cz/) is an open source source-control system designed to handle large and small projects with speed and convenience. The Linux kernel and Ruby on Rails projects also rely on Git for version control. The complete list of Android projects in the Git repository appears at http://android.git.kernel.org/.
You can download any of these projects using the tools provided by Git and described at the product’s web site. Some of the primary projects include Dalvik, frameworks/base (the android.jar file), Linux kernel, and a number of external libraries such as Apache HTTP librar-ies (apache-http). The core Android applications are also hosted here. Some of these core applications include: AlarmClock, Browser, Calculator, Calendar, Camera, Contacts, Email, GoogleSearch, HTML Viewer, IM, Launcher, Mms, Music, PackageInstaller, Phone, Settings,SoundRecorder, Stk, Sync, Updater, and VoiceDialer.
The Android projects also include the “Provider” projects. “Provider” projects are like databases in Android that wrap their data into RESTful services. These projects are Calen-darProvider, ContactsProvider, DownloadProvider, DrmProvider, GoogleContactsProvider, GoogleSubscribedFeedsProvider, ImProvider, MediaProvider, SettingsProvider, Subscribed-FeedsProvider, and TelephonyProvider.
As a programmer, you will be most interested in the source code that makes up the android.jar file. (If you’d rather download the entire platform and build it yourself, refer to the documentation available at http://source.android.com/download.) You can download the source for this .jar file by typing in the following URL:
http://git.source.android.com/
?p=platform/frameworks/base.git;a=snapshot;h=HEAD;sf=tgz
This is one of the general-purpose URLs you can use to download Git projects. On Win-dows, you can unzip this file using pkzip. Although you can download and unzip the source, it might be more convenient to just look at these files online if you don’t need to debug the source code through your IDE. Git also allows you to do this. For example, you can browse through android.jar source files by visiting this URL:
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=summary
However, you have to do some work after you visit this page. Pick grep from the drop-down list and enter some text in the search box. Click one of the resulting file names to open that source file in your browser. This facility is convenient for a quick lookup of source code.
At times the file you are looking for might not be in the frameworks/base directory or proj-ect. In that case, you need to find the list of projects and search each one step by step. The URL for this list is http://android.git.kernel.org/.
You cannot grep across all projects, so you will need to know which project belongs to which facility in Android. For example, the graphics-related libraries in the Skia project are available here:
http://android.git.kernel.org/?p=platform/external/skia.git;a=summary
As indicated, Android is a platform and not just one project. You can see the scope and the number of projects at http://source.android.com/projects.
The source code of Android and all its projects is managed by the Git source-code control system. Git (http://git.or.cz/) is an open source source-control system designed to handle large and small projects with speed and convenience. The Linux kernel and Ruby on Rails projects also rely on Git for version control. The complete list of Android projects in the Git repository appears at http://android.git.kernel.org/.
You can download any of these projects using the tools provided by Git and described at the product’s web site. Some of the primary projects include Dalvik, frameworks/base (the android.jar file), Linux kernel, and a number of external libraries such as Apache HTTP librar-ies (apache-http). The core Android applications are also hosted here. Some of these core applications include: AlarmClock, Browser, Calculator, Calendar, Camera, Contacts, Email, GoogleSearch, HTML Viewer, IM, Launcher, Mms, Music, PackageInstaller, Phone, Settings,SoundRecorder, Stk, Sync, Updater, and VoiceDialer.
The Android projects also include the “Provider” projects. “Provider” projects are like databases in Android that wrap their data into RESTful services. These projects are Calen-darProvider, ContactsProvider, DownloadProvider, DrmProvider, GoogleContactsProvider, GoogleSubscribedFeedsProvider, ImProvider, MediaProvider, SettingsProvider, Subscribed-FeedsProvider, and TelephonyProvider.
As a programmer, you will be most interested in the source code that makes up the android.jar file. (If you’d rather download the entire platform and build it yourself, refer to the documentation available at http://source.android.com/download.) You can download the source for this .jar file by typing in the following URL:
http://git.source.android.com/
?p=platform/frameworks/base.git;a=snapshot;h=HEAD;sf=tgz
This is one of the general-purpose URLs you can use to download Git projects. On Win-dows, you can unzip this file using pkzip. Although you can download and unzip the source, it might be more convenient to just look at these files online if you don’t need to debug the source code through your IDE. Git also allows you to do this. For example, you can browse through android.jar source files by visiting this URL:
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=summary
However, you have to do some work after you visit this page. Pick grep from the drop-down list and enter some text in the search box. Click one of the resulting file names to open that source file in your browser. This facility is convenient for a quick lookup of source code.
At times the file you are looking for might not be in the frameworks/base directory or proj-ect. In that case, you need to find the list of projects and search each one step by step. The URL for this list is http://android.git.kernel.org/.
You cannot grep across all projects, so you will need to know which project belongs to which facility in Android. For example, the graphics-related libraries in the Skia project are available here:
http://android.git.kernel.org/?p=platform/external/skia.git;a=summary
Read 69 times
Published in
Java
John
Latest from John
More in this category:
« Developing an End-User Application with the Android SDK
Getting Your Feet Wet »