The libraries
The
libraries component also share its space with runtime component. The libraries
component acts as a translation layer between the kernel and the application
framework. The libraries are written in C/C++ but are exposed to developers through
a Java API. Developers can use the Java application framework to access the
underlying core C/C++ libraries. Some of the core libraries include the
following:
LibWebCore : Allows access
to the web browtheser
Media Libraries :Allow
access to popular audio – and video- recording and playback functions
Graphic libraries : Allows access to 2D and 3D graphics
drawing engines
The
runtime component consist of the Dalkviik virtual machines that will interact
and run applications. The virtual machines is an important part of the android
operating system and executes system third-party applications.
The Dalvik
Virtual Machine
Dan
Bornstein originally wrote the Dalvik virtual machine. He named it after a
small fishing village in Iceland where
he believed one of his ancestors once
originated. The dalvik VM was written
primarily to allow application execution on devices with very limited
resources. Typically, mobile phones will fall into this category because they
are limited by processing power, the amount of memory availabl, and a short
battery life.
WHAT IS A VIRTUAL MACHINE?
A
virtual machine is an isolated, guest operating
system running whitin another host operating system. A virtual machine
will execute applications as if they were
running on a physical machine.
One of the main advantages of a virtual machine is portability. Regardless
of the underlying hardware, the code
that you write will work on the VM. T o you as a developer, this means that you
write your code only once and can execute it on any hardware platform that runs
a compatible VM.
The
Dalvik VM executes. dex files. A. dex
file made by taking the compiled Java.class or.jar files and consolidating all
the constants and data within each.class file into a shared constant pool (see
Figure 1-3). The dx tool, included in the Android SDK, performs this
conversion.
Figure
1-3. Conversion of a.jar file to a.dex file
Table
1-1. A File Size Comparison (in Bytes) of .jar and .dex Files
Application
|
Uncompressed .jar
|
Compresses .jar
|
Uncompressed .dex
|
Common system
|
21445320 = 100 %
|
10662048 = 50 %
|
10311972 = 48 %
|
Libraries
|
|||
Web browser app
|
470312 = 100 %
|
232065 = 49 %
|
209248 = 44 %
|
Alarm clock app
|
119200 = 100 %
|
61658 = 52 %
|
53020 = 44 %
|
The Application Framework
The
application framework is one of the building blocks for the final system or
end-user applicantions. Theframework provides a suite of services or systems
that a developer will find useful when
writing applications. Commonly referred to as the API (application programming
interface) component, this framework will provide a developer with access to
user interface components such as buttons and text boxes, common content
providers so that apps may share data between them, a notification manager so
that device owners can be alerted of events, and an activity manager for
managing the lifecycle of applications.
As
a developer, you will write code and use the APIs in Java programming language.
Listing 1-1, taken from Google’s sample API demos(http://developer.android.com/resources/samples/ApiDemos/index.html)
, demonstates how to use the application framework to play a video file. The
import statements in bold allow acces to the core C/C++ libraries through a
Java API.
Listing 1-1. A Video Player Demo (Courtesy Google,
Inc.)
/*
*Copyright
© 2009 The Android Open Source Project
*
*
Licensed under the Apache License, Version 2.0 (the “License”);
*
You may not use this file except in compliance with the license.
*
You may obtain a copy of the License at
*
*
htttp://www.apache.org/licenses/LICENSE-2.0
*
*
Unless required by applicable law or agreed to in writing, software
*
distributed under the Licences is distributed on an “AS IS” BASIS,
*
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
See the License for the specific language governing permissions and
*
limitations under the License.
*/
Package
com.example.android.apis.media;
importcom.example.android.apis.R;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.widget.MediaController;
importandroid.widget.Toast;
importandroid.widget.VideoView;
public
class VideoViewDemo Activity {
/**
* TODO: Set the path variable to a
streamin video URL or a local media
* file path.
*/
private
String ath=””;
privateVideoViewmVideoView;
@override
public
void onCreate(Bundle icicle){
super.onCreate(icile);
setContentView(R.layout.videoview);
mVideoView = (VideoView)
findViewById(R.id.surface_view);
if
(path == “ “){
//Tell the user to provide a media
file URL/path.
Toast.makeText(
VideoViewDemo.this,
“Please
edit VideoViewDemoAcivity, and set path”
+
” variable to your media file URL/path “,
Toast.LENGTH_LONG).show();
}else{
Perpustakaan
Komponen perpustakaan juga berbagi ruang dengan komponen runtime. Perpustakaan komponen bertindak sebagai lapisan terjemahan antara kernel dan kerangka aplikasi. Perpustakaan yang ditulis dalam C / C ++ namun dikembangkan melalui API Java. Pengembang dapat menggunakan kerangka aplikasi Java untuk mengakses dasar inti C / C ++ perpustakaan. Beberapa perpustakaan inti meliputi:
LibWebCore: Memungkinkan akses ke web browser
Perpustakaan Media: Memungkinkan akses ke audio populer - dan perekaman video-dan fungsi media pemutar
Perpustakaan grafis: Memungkinkan akses ke 2D dan 3D mesin gambar grafis
Komponen runtime terdiri dari mesin virtual Dalkviik yang akan berinteraksi dan menjalankan aplikasi. Mesin virtual adalah bagian penting dari sistem operasi android dan mengeksekusi sistem aplikasi pihak ketiga.
Dalvik Virtual Machine
Dan Bornstein awalnya menulis mesin virtual Dalvik. Dia memberi nama itu setelah sebuah desa nelayan kecil di Islandia di mana ia percaya salah satu nenek moyangnya berasal. The Dalvik VM ditulis terutama untuk memungkinkan eksekusi aplikasi pada perangkat dengan sumber daya sangat terbatas. Biasanya, ponsel akan jatuh ke dalam kategori ini karena mereka dibatasi oleh kekuatan pemrosesan, jumlah memori yang tersedia, dan baterai pendek.
APAKAH MESIN VIRTUAL ITU?
Sebuah mesin virtual terisolasi, pengguna sistem operasi berjalan dalam sistem operasi host lain. Sebuah mesin virtual akan mengeksekusi aplikasi seolah-olah mereka berjalan pada mesin fisik. Salah satu keuntungan utama dari mesin virtual adalah portabilitas. Terlepas dari perangkat keras yang mendasari, kode yang Anda tulis akan bekerja pada VM. Untuk Anda sebagai pengembang, ini berarti bahwa Anda menulis kode Anda hanya sekali dan dapat melaksanakannya pada perangkat keras platform yang menjalankan VM kompatibel.
Dalvik VM mengeksekusi. file dex. File dex A. dibuat dengan mengambil Java.class atau .jar file dikompilasi dan mengkonsolidasikan semua konstanta dan data dalam setiap .class file ke kolam konstan bersama (lihat Gambar 1-3). Perangkat dx , termasuk dalam SDK Android, melakukan konversi ini. Setelah konversi, .dex file – file mempunyai ukuran file yang lebih kecil yang sangat signifikan, seperti yang ditunjukkan pada tabel 1 – 1.
Tabel 1-1. Sebuah Ukuran File
Perbandingan (dalam Bytes) File .jar dan Dex
Aplikasi terkompresi .jar Kompres .jarDex terkompresi
Sistem umum 21445320 = 100% 10662048 = 50% 10311972 = 48%
Perpustakaan
Web aplikasi browser 470.312 = 100% 232.065 = 49% 209.248 = 44%
Jam alarm app 119.200 = 100% 61.658 = 52% 53020 = 44%
Aplikasi Kerangka
Kerangka aplikasi adalah salah satu blok – blok bangunan untuk sistem akhir atau pengguna aplikasi - aplikasi akhir. Kerangka ini menyediakan paket layanan atau sistem di mana pengembang akan menemukan kegunaan saat menulis aplikasi. Biasanya disebut sebagai komponen API (application programming interface), kerangka kerja ini akan menyediakan pengembang dengan akses ke pengguna komponen antarmuka seperti tombol dan kotak teks, penyedia konten umum sehingga aplikasi dapat berbagi data di antara mereka, manajer pemberitahuan sehingga pemilik perangkat dapat memberitahu peristiwa, dan manajer kegiatan untuk mengelola siklus hidup aplikasi.
Sebagai pengembang, Anda akan menulis kode dan menggunakan API dalam bahasa pemrograman Java. Listing 1-1, diambil dari demo sampel API Google (http://developer.android.com/resources/samples/ApiDemos/index.html), demonstates bagaimana menggunakan kerangka aplikasi untuk memutar file video. Laporan impor dalam huruf tebal memungkinkan akses ke inti C / C ++ perpustakaan melalui API Java.
Listing 1-1. Sebuah Video Player Demo (Courtesy Google, Inc.)
/ *
* Copyright © 2009 Android Open Source Project
*
* Izin bawah Lisensi Apache, Versi 2.0 ("Lisensi");
* Anda tidak dapat menggunakan file ini kecuali sesuai dengan lisensi.
* Anda dapat memperoleh salinan Lisensi di
*
* Htttp: //www.apache.org/licenses/LICENSE-2.0
*
* Kecuali dibutuhkan oleh hukum yang berlaku atau disetujui secara tertulis, perangkat lunak
* Didistribusikan di bawah Lisensi didistribusikan pada "APA ADANYA",
* TANPA JAMINAN ATAU KONDISI APAPUN, baik tersurat maupun tersirat.
* Lihat Lisensi untuk bahasa tertentu yang mengatur izin dan
* Keterbatasan di bawah Lisensi.
* /
Com.example.android.apis.media paket;
impor com.example.android.apis.R;
impor android.app.Activity;
impor android.os.Bundle;
impor android.widget.MediaController;
impor android.widget.Toast;
impor android.widget.VideoView;
public class VideoViewDemo Kegiatan {
/ **
* TODO: Set variabel path ke URL video streamin atau media lokal
* Path file.
* /
swasta String ath = "";
swasta VideoView mVideoView;
@ Override
public void OnCreate (Bundle es) {
super.onCreate (icile);
setContentView (R.layout.videoview);
mVideoView = (VideoView) findViewById (R.id.surface_view);
jika (path == "") {
// Katakan pengguna untuk memberikan file media URL / path.
Toast.makeText (
VideoViewDemo.this,
"Silakan mengedit VideoViewDemo Acivity, dan set path"
Aplikasi terkompresi .jar Kompres .jarDex terkompresi
Sistem umum 21445320 = 100% 10662048 = 50% 10311972 = 48%
Perpustakaan
Web aplikasi browser 470.312 = 100% 232.065 = 49% 209.248 = 44%
Jam alarm app 119.200 = 100% 61.658 = 52% 53020 = 44%
Aplikasi Kerangka
Kerangka aplikasi adalah salah satu blok – blok bangunan untuk sistem akhir atau pengguna aplikasi - aplikasi akhir. Kerangka ini menyediakan paket layanan atau sistem di mana pengembang akan menemukan kegunaan saat menulis aplikasi. Biasanya disebut sebagai komponen API (application programming interface), kerangka kerja ini akan menyediakan pengembang dengan akses ke pengguna komponen antarmuka seperti tombol dan kotak teks, penyedia konten umum sehingga aplikasi dapat berbagi data di antara mereka, manajer pemberitahuan sehingga pemilik perangkat dapat memberitahu peristiwa, dan manajer kegiatan untuk mengelola siklus hidup aplikasi.
Sebagai pengembang, Anda akan menulis kode dan menggunakan API dalam bahasa pemrograman Java. Listing 1-1, diambil dari demo sampel API Google (http://developer.android.com/resources/samples/ApiDemos/index.html), demonstates bagaimana menggunakan kerangka aplikasi untuk memutar file video. Laporan impor dalam huruf tebal memungkinkan akses ke inti C / C ++ perpustakaan melalui API Java.
Listing 1-1. Sebuah Video Player Demo (Courtesy Google, Inc.)
/ *
* Copyright © 2009 Android Open Source Project
*
* Izin bawah Lisensi Apache, Versi 2.0 ("Lisensi");
* Anda tidak dapat menggunakan file ini kecuali sesuai dengan lisensi.
* Anda dapat memperoleh salinan Lisensi di
*
* Htttp: //www.apache.org/licenses/LICENSE-2.0
*
* Kecuali dibutuhkan oleh hukum yang berlaku atau disetujui secara tertulis, perangkat lunak
* Didistribusikan di bawah Lisensi didistribusikan pada "APA ADANYA",
* TANPA JAMINAN ATAU KONDISI APAPUN, baik tersurat maupun tersirat.
* Lihat Lisensi untuk bahasa tertentu yang mengatur izin dan
* Keterbatasan di bawah Lisensi.
* /
Com.example.android.apis.media paket;
impor com.example.android.apis.R;
impor android.app.Activity;
impor android.os.Bundle;
impor android.widget.MediaController;
impor android.widget.Toast;
impor android.widget.VideoView;
public class VideoViewDemo Kegiatan {
/ **
* TODO: Set variabel path ke URL video streamin atau media lokal
* Path file.
* /
swasta String ath = "";
swasta VideoView mVideoView;
@ Override
public void OnCreate (Bundle es) {
super.onCreate (icile);
setContentView (R.layout.videoview);
mVideoView = (VideoView) findViewById (R.id.surface_view);
jika (path == "") {
// Katakan pengguna untuk memberikan file media URL / path.
Toast.makeText (
VideoViewDemo.this,
"Silakan mengedit VideoViewDemo Acivity, dan set path"
+
"Variabel untuk Anda file media URL / path",
Toast.LENGTH_LONG) .show ();
} else {
Toast.LENGTH_LONG) .show ();
} else {