Android 盘点所有Dialog 对话框 大合集 详解

雨松MOMO带大家盘点Android 中的对话框

今天我用自己写的一个Demo 和大家详细介绍一个Android中的对话框的使用技巧。


1.确定取消对话框

对话框中有2个按钮   通过调用 setPositiveButton 方法 和 setNegativeButton 方法 可以设置按钮的显示内容以及按钮的监听事件。

我们使用AlerDialog 创建对话框

  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);

使用builder设置对话框的title button icon 等等

  1. builder.setIcon(R.drawable.icon);
  2.        builder.setTitle(“你确定要离开吗?”);
  3.        builder.setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
  4.            public void onClick(DialogInterface dialog, int whichButton) {
  5.                //这里添加点击确定后的逻辑
  6.                showDialog(“你选择了确定”);
  7.            }
  8.        });
  9.        builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
  10.            public void onClick(DialogInterface dialog, int whichButton) {
  11.                //这里添加点击确定后的逻辑
  12.                showDialog(“你选择了取消”);
  13.            }
  14.        });
  15.        builder.create().show();

这个dialog用于现实onClick后监听的内容信息

  1. private void showDialog(String str) {
  2. w AlertDialog.Builder(MainDialog.this)
  3.      .setMessage(str)
  4.      .show();
  5. }

2.多个按钮信息框

  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);
  2. builder.setIcon(R.drawable.icon);
  3. builder.setTitle(“投票”);
  4. builder.setMessage(“您认为什么样的内容能吸引您?”);
  5. builder.setPositiveButton(“有趣味的”, new DialogInterface.OnClickListener() {
  6.     public void onClick(DialogInterface dialog, int whichButton) {
  7.         showDialog(“你选择了有趣味的”);
  8.     }
  9. });
  10. builder.setNeutralButton(“有思想的”, new DialogInterface.OnClickListener() {
  11.     public void onClick(DialogInterface dialog, int whichButton) {
  12.         showDialog(“你选择了有思想的”);
  13.     }
  14. });
  15. builder.setNegativeButton(“主题强的”, new DialogInterface.OnClickListener() {
  16.     public void onClick(DialogInterface dialog, int whichButton) {
  17.         showDialog(“你选择了主题强的”);
  18.     }
  19. });
  20. builder.create().show();

3.列表框

这个数组用于列表选择

  1. final String[] mItems = {“item0″,”item1″,”itme2″,”item3″,”itme4″,”item5″,”item6”};
  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);
  2.         builder.setTitle(“列表选择框”);
  3.         builder.setItems(mItems, new DialogInterface.OnClickListener() {
  4.             public void onClick(DialogInterface dialog, int which) {
  5.                 //点击后弹出窗口选择了第几项
  6.                 showDialog(“你选择的id为” + which + ” , ” + mItems[which]);
  7.             }
  8.         });
  9.         builder.create().show();

4.单项选择列表框

mSingleChoice 用于记录单选中的ID

  1. int mSingleChoiceID = -1;
  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);
  2. mSingleChoiceID = -1;
  3. builder.setIcon(R.drawable.icon);
  4.     builder.setTitle(“单项选择”);
  5.     builder.setSingleChoiceItems(mItems, 0, new DialogInterface.OnClickListener() {
  6.         public void onClick(DialogInterface dialog, int whichButton) {
  7.                 mSingleChoiceID = whichButton;
  8.                 showDialog(“你选择的id为” + whichButton + ” , ” + mItems[whichButton]);
  9.         }
  10.     });
  11.     builder.setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
  12.         public void onClick(DialogInterface dialog, int whichButton) {
  13.             if(mSingleChoiceID > 0) {
  14.             showDialog(“你选择的是” + mSingleChoiceID);
  15.             }
  16.         }
  17.     });
  18.     builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
  19.         public void onClick(DialogInterface dialog, int whichButton) {
  20.         }
  21.     });
  22.    builder.create().show();

5.进度条框

点击进度条框按钮后 开启一个线程计算读取的进度 假设读取结束为 100
Progress在小于100的时候一直在线程中做循环++ 只到读取结束后,停止线程。

  1.           mProgressDialog = new ProgressDialog(MainDialog.this);
  2.      mProgressDialog.setIcon(R.drawable.icon);
  3.      mProgressDialog.setTitle(“进度条窗口”);
  4.      mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  5.      mProgressDialog.setMax(MAX_PROGRESS);
  6.      mProgressDialog.setButton(“确定”, new DialogInterface.OnClickListener() {
  7.          public void onClick(DialogInterface dialog, int whichButton) {
  8.              //这里添加点击后的逻辑
  9.          }
  10.      });
  11.      mProgressDialog.setButton2(“取消”, new DialogInterface.OnClickListener() {
  12.          public void onClick(DialogInterface dialog, int whichButton) {
  13.              //这里添加点击后的逻辑
  14.          }
  15.      });
  16.      mProgressDialog.show();
  17.      new Thread(this).start();
  18. ic void run() {
  19. int Progress = 0;
  20. while(Progress < MAX_PROGRESS) {
  21. try {
  22.     Thread.sleep(100);
  23.     Progress++;
  24.     mProgressDialog.incrementProgressBy(1);
  25. } catch (InterruptedException e) {
  26.     // TODO Auto-generated catch block
  27.     e.printStackTrace();
  28. }
  29. }

6.多项选择列表框

MultiChoiceID 用于记录多选选中的id号 存在ArrayList中
选中后 add 进ArrayList
取消选中后 remove 出ArrayList

  1. ArrayList <Integer>MultiChoiceID = new ArrayList <Integer>();
  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);
  2. MultiChoiceID.clear();
  3. builder.setIcon(R.drawable.icon);
  4.     builder.setTitle(“多项选择”);
  5.     builder.setMultiChoiceItems(mItems,
  6.             new boolean[]{false, false, false, false, false, false, false},
  7.             new DialogInterface.OnMultiChoiceClickListener() {
  8.                 public void onClick(DialogInterface dialog, int whichButton,
  9.                         boolean isChecked) {
  10.                    if(isChecked) {
  11.                        MultiChoiceID.add(whichButton);
  12.                        showDialog(“你选择的id为” + whichButton + ” , ” + mItems[whichButton]);
  13.                    }else {
  14.                        MultiChoiceID.remove(whichButton);
  15.                    }
  16.                 }
  17.             });
  18.     builder.setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
  19.         public void onClick(DialogInterface dialog, int whichButton) {
  20.             String str = “”;
  21.             int size = MultiChoiceID.size();
  22.             for (int i = 0 ;i < size; i++) {
  23.             str+= mItems[MultiChoiceID.get(i)] + “, “;
  24.             }
  25.             showDialog(“你选择的是” + str);
  26.         }
  27.     });
  28.     builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
  29.         public void onClick(DialogInterface dialog, int whichButton) {
  30.         }
  31.     });
  32.    builder.create().show();

7.自定义布局


讲到自定义布局我就得多说一说了,为什么要多说一说呢?
其实自定义布局在Android的开发中非常重要 因为它能让开发者做出自己五彩缤纷的Activity 而不用去使用系统枯燥的界面。

自定义dialog有什么好处?

比如我们在开发过长当中 要通过介绍系统发送的一个广播弹出一个dialog . 但是dialog必需是基于activity才能呈现出来 如果没有activity 的话 程序就会崩溃。所以我们可以写一个自定义的 dialog 把它定义成一个activity
这样我们收到一条打开dialog的广播后 直接启动这个 activity  程序正常运行~~

这就是自定义dialog的好处。

注明:下面这个例子只是写了自定义dialog 没有把它单独的写在一个activity中 如果须要的话 可以自己改一下。

  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this);
  2.  LayoutInflater factory = LayoutInflater.from(this);
  3.  final View textEntryView = factory.inflate(R.layout.test, null);
  4.      builder.setIcon(R.drawable.icon);
  5.      builder.setTitle(“自定义输入框”);
  6.      builder.setView(textEntryView);
  7.      builder.setPositiveButton(“确定”, new DialogInterface.OnClickListener() {
  8.          public void onClick(DialogInterface dialog, int whichButton) {
  9.          EditText userName = (EditText) textEntryView.findViewById(R.id.etUserName);
  10.          EditText password = (EditText) textEntryView.findViewById(R.id.etPassWord);
  11.          showDialog(“姓名 :”  + userName.getText().toString()  + “密码:” + password.getText().toString() );
  12.          }
  13.      });
  14.      builder.setNegativeButton(“取消”, new DialogInterface.OnClickListener() {
  15.          public void onClick(DialogInterface dialog, int whichButton) {
  16.          }
  17.      });
  18.    builder.create().show();
  1. <span style=”color:#000000;”><?xml version=”1.0″ encoding=”utf-8″?>
  2. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
  3. android:layout_height=”wrap_content”
  4. android:layout_width=”wrap_content”
  5. android:orientation=”horizontal”
  6. android:id=”@+id/dialog”>
  7. <LinearLayout
  8. android:layout_height=”wrap_content”
  9. android:layout_width=”wrap_content”
  10. android:orientation=”horizontal”
  11. android:id=”@+id/dialogname”>
  12. <TextView android:layout_height=”wrap_content”
  13.    android:layout_width=”wrap_content”
  14.   android:id=”@+id/tvUserName”
  15.   android:text=”姓名:” />
  16. <EditText android:layout_height=”wrap_content”
  17.   android:layout_width=”wrap_content”
  18.   android:id=”@+id/etUserName”
  19.   android:minWidth=”200dip”/>
  20. </LinearLayout>
  21. <LinearLayout
  22. android:layout_height=”wrap_content”
  23. android:layout_width=”wrap_content”
  24. android:orientation=”horizontal”
  25. android:id=”@+id/dialognum”
  26.  android:layout_below=”@+id/dialogname”
  27. >
  28.   <TextView android:layout_height=”wrap_content”
  29.    android:layout_width=”wrap_content”
  30.   android:id=”@+id/tvPassWord”
  31.   android:text=”密码:” />
  32. <EditText android:layout_height=”wrap_content”
  33.   android:layout_width=”wrap_content”
  34.   android:id=”@+id/etPassWord”
  35.   android:minWidth=”200dip”/>
  36.  </LinearLayout>
  37.   </RelativeLayout></span>


8.读取进度框

显示一个正在转圈的进度条loading

 

  1. mProgressDialog = new ProgressDialog(this);
  2.  mProgressDialog.setTitle(“读取ing”);
  3.  mProgressDialog.setMessage(“正在读取中请稍候”);
  4.  mProgressDialog.setIndeterminate(true);
  5.  mProgressDialog.setCancelable(true);
  6.  mProgressDialog.show();

最后如果你还是觉得我写的不够详细 不要紧我把源代码的下载地址贴出来 欢迎大家一起讨论学习 雨松MOMO希望可以和大家一起进步。

15 Best Free Android Games You Love To Play

Android is open sources OS (operating System) for smart phones. Google’s mobile platform, the second most popular operating system using smart phones. Android has a big library of free apps and its growing day by day. Android Market has a big collection of free apps and free games, Android gaming market is also growing as well. So today we come with some best Android games for free download, you would love playing.

Our Last article, related to games appreciated by our readers a lot- best Linux 3D Games For free to use. And again this time we catch best android games for free to use. if you have Android phone then you must try these free Android games for kill free time and having fun.

I have been searching free games for android to make a best list for Android platform users. And finally i got the best list of free games for Android smart phones for having fun and enjoy. These games are the latest version of year 2011.

 

I hope Android platform users whom loves to play games on their smart phones will love to use these free android games. here we have listed 15 best free android games you love to play. You can share your views in our comment section below.

1. Bubble Blast 2

2. Angry Birds


3.  Yoo Ninja

4. Paradise Island

5. Drag Racing

6. Unblock Me

7. Mouse Trap

8. Paper Toss

9. Ant Smasher

10. iRunner

11. SpeedX

12. Air Control

13. Speed Anatomy

14. Aporkalypse Free

15. Math Maniac

 

Android开发几个必去的网站

1 Eoe Android开发者门户

简介:有许多技术性文章,人气很旺,经常有些很酷的android设置,android新闻报道的不是很及时

网址: http://www.eoeandroid.com/portal.ph

移动App资讯站(推荐)

简介: Android开发者必去的一个网站,可以及时了解android开发全球最新消息,同时也有最新手机软件开发业内报道有句很经典的话
只有NEWS.

网址: http://www.ydapp.com/

3 Android Police

简介:国外的网站,主要报道最新Android产品

网址:http://www.androidpolice.com/

有米广告

简介:这个应该大家不陌生吧国内第一家移动APP广告商 ,广告单价很高

网址: http://www.youmi.net/

移动Labs(中国移动研究院)

简介:经常出一些经典的文章比较深入的说明移动开发行业动态.了解行业走向,及发展趋势.

网址: http://labs.chinamobile.com/

Android Developer Income Report

A lot of people says that there is no real money in the Android development. They say that if you want to make money you should write for iPhone, iPad and all other iThings… This is not true! I am not a one of guys that is making thousands of dollars but my income seems to be steady and is still growing.

Moreover I am not one of top developers nor any of my apps have been promoted by Android Market. I am just an one among of thousands of Android developers with not to well known apps. And what may be really surprising all my apps are free as Google do not allow developers from my country (Poland) to sell apps via Android Market!

So keep in mind these facts:

  1. None of my apps has been ever promoted in Top of Android Market
  2. I am providing only free apps (mostly due of Android Market limitations)
  3. Even if I would be able to sell apps I would not use it as main income source… (I believe that you still can make more from ads…)

All my income comes from ads that are included in my mobile apps for Android. Here is the list with current number of downloads:

  1. X-Ray Scanner (over 268 000 downloads)
  2. Cracked Screen (over 182 000 downloads)
  3. Virtual Drums (over 20 000 downloads)
  4. Daily Beauty Tips (over 11 000 downloads)
  5. Don’t push it (over 6 500 downloads)
  6. WP Stats (over 4 000 downloads)

I have started to learn Android Development on April 2010. My first application was ready to be published on May. And it bring me first few dollars… I was not satisfied as I have been expecting that this app (WP Stats) will be really popular… Unfortunately it wasn’t… Anyway I have published a few more apps that got a lot more popularity… So here is my total income breakdown:

  • May 2010 – $4.92
  • June 2010 – $138.87
  • July 2010 – $538.26
  • August 2010 – $920.00
  • September 2010 – $1545.45
  • October 2010 – $1059.31

October looks to be lower in earning but it happened only because I have not been updating any of my apps in this month (I have been moving to new house and had no time for it…).

So as you may see income has not been high on the begging but with each month with regular updates and new apps it has been growing very rapidly!

And I will say it again… I have not made a single cent from selling apps – all my income is only from ads. This month I am preparing new updates for my apps and I am finalizing some new ideas… so my income should start growing up again…

All comments are welcome and very desired.

Android application四大组件的作用

我简要的介绍下这四大组件,希望与你们一起学习共同进步!
Activity:Activity是Android程序与用户交互的窗口,是Android构造块中最基本的一种,它需要为保持各界面的状态,做很多持久化的事情,妥善管理生命周期以及一些跳转逻辑

service:后台服务于Activity,封装有一个完整的功能逻辑实现,接受上层指令,完成相关的食物,定义好需要接受的Intent提供同步和异步的接口

Content Provider:是Android提供的第三方应用数据的访问方案,可以派生Content Provider类,对外提供数据,可以像数据库一样进行选择排序,屏蔽内部数据的存储细节,向外提供统一的借口模型,大大简化上层应用,对数据的整合提供了更方便的途径

BroadCast Receiver:接受一种或者多种Intent作触发事件,接受相关消息,做一些简单处理,转换成一条Notification,统一了Android的事件广播模型

Android多线程断点续传下载文件类设计

对于Android平台,很多网友可能考虑开发一个软件商店,对于Android平台上如何实现断点续传操作呢? 这里给大家一些思路和原理的介绍,同时在Android手机上要考虑的一些事情。

1. 流量控制,获取运营商的接入方式,比如说使用移动网络接入,尽可能的提示用户切换WiFi或提示,限制下载的流量以节省话费。

2. 屏幕锁控制,屏幕锁屏后导致应用会被挂起,当然Android提供了PowerManager.WakeLock来控制。

3. 对于断点续传,这要追溯到Http 1.1的特性了,主要是获取文件大小,如果这个无法读取的话,那么就无法断点续传了只能使用chunked模式了,当然获取远程服务器上文件的大小可以通过Http的响应头查找Content-Length。

4. 获取上次文件的更改时间,对于断点续传来说比较有风险的就是 继续下载的文件和早期下载的在server上有变动,这将会导致续传时下载的文件版本和原始的不同,一般有两种解决方法,早期我们配置服务器时通过Last-Modified这个http header获取文件上次修改时间,不过本次Android开发网推荐使用更为强大的ETag,ETag一般用于解决同一个URL处理不同返回相应,比如Session认证,多国语言,以及部分黑帽的SEO中。具体的实现大家可以参考RFC文档。

5. 考虑服务器的3xx的返回,对于专业的下载文件服务器会考虑到负载平衡问题,这就涉及到重定向问题,处理重定向使用Android的Apache库处理比较好。

6. 至于多线程,这里CWJ提示大家可能存在独立的线程下载一个文件,和多个线程分块下载单个文件之分,其中后者需要考虑上次下载数据是否存在问题,同时如果服务器不支持文件大小获取,则无法通过分段下载数据,因为不知道如何分段,所以在chunked模式中,只能使用一个线程下载一个文件,而不是多个线程下载一个文件。

7. 下载后的数据效验,可以考虑CRC等方式,当然对于一般的传输只要逻辑不出现问题,基本上不会有偏差。

8. 考虑DRM问题,这个问题在国内用的比较少,而国外的受数字保护的音乐和视频,需要额外的获取证书等。

9. 重试次数,对于一个文件可能在本次网络传输中受到问题,尤其是移动网络,所以可以设置一定的重试次数,让任务单独的走下去。

10. 线程开发方式,这里如果你的Java基础比较好,推荐直接使用Java并发库API比较好,如果过去只做过Java开发使用Thread即可,如果Java技术不过关可以Android封装的AsyncTask。

原文地址:http://www.android123.com.cn/androidkaifa/932.html

android 如何保存簡單的配置信息(SharedPreferences、File和Properties)

我們知道在android的開發中,保存項目私有數據的存儲方式我們可以使用:SharedPreferences,File,SQLite,Network.四種方式,而要用到應
用程序之間數據的共享要使用ContentProvider 。那今天我們只敘述一下僅僅保存一些我們登錄等的一些配置信息的數據,也就是說用到的數
據量都不是很大,那麼我們就可以選擇SharedPreferences和File的方式。這裡只針對性的結合File和Properties進行敘述。
一。SharedPreferences

1. 它可以保存上一次用戶所做的修改或者自定義參數的設定,當再次啟動程序後依然可以保持原有的設置。這裡只說明一下使用方式。比如下
面的代碼在OnCreate中使用:

SharedPreferences mSharedPreferences = getSharedPreferences(“list”,MODE_PRIVATE);

String mTempString = mSharedPreferences.getString(“config”,”default”);

其中”list”是SharedPreferences的文件的名字,SharedPreferences是以鍵值映射的關係存放數據。不過多解釋,你也可以這樣用:

SharedPreferences mSharedPreferences = getPreferences(MODE_PRIVATE);

這樣默認的文件名是activity的名字。

2. 退出activity的時候保存數據,在OnPause中使用:

SharedPreferences mSharedPreferences = getSharedPreferences(“list”,    MODE_PRIVATE);

mSharedPreferences.edit().putString(“config”,”data” ).commit();

3. SharedPreferences 是以xml文件的方式自動保存的,在DDMS中的FileExplorer中展開/data/data/包名/shared-prefs下面就是SharedPreferences文件。

4. SharedPreferences文件只可以用來存放基本的數據類型。
二。結合File和Properties進行保存。

A Properties object is a Hashtable where the keys and values must be Strings. Each property can have a default Properties list which specifies the default values to be used when a given key is not found in this Properties instance.

1.所以,Properties對象也是一個哈希表,也是一個鍵值對應的關係,因此和上面的操作相似。下面看具體的程序。

public class File_ByProperties extends Activity {

private boolean mStatus;

private TextView mShowStatus;
/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

mShowStatus = (TextView) findViewById(R.id.show);

load();

}
private void load() {

// TODO Auto-generated method stub

Properties mProperties = new Properties();

try {

FileInputStream mInputStream = openFileInput(“configuration”);

mProperties.load(mInputStream);

mStatus = Boolean.valueOf(mProperties.get(“status”).toString());

mShowStatus.setText(“the status is : ” + mStatus);

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

System.out.println(e.toString());

} catch (IOException e) {

System.out.println(e.toString());

}

}
@Override

public boolean onKeyDown(int keyCode, KeyEvent event) {

// TODO Auto-generated method stub

if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {

mStatus = !mStatus;

mShowStatus.setText(“the status is : ” + mStatus);

}

return super.onKeyDown(keyCode, event);

}
@Override

protected void onPause() {

// TODO Auto-generated method stub

super.onPause();

Properties mProperties = new Properties();

if (mProperties.containsKey(“status”)) {

mProperties.remove(“status”);

}

mProperties.put(“status”, String.valueOf(mStatus));

try {

FileOutputStream mOutputStream = openFileOutput(“configuration”,     MODE_WORLD_WRITEABLE);

mProperties.store(mOutputStream, null);

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}
}

2. 在DDMS中的FileExplorer中展開/data/data/包名/files,可以查看到該文件。
三。你還可以將一個靜態的文件放到res/raw/下面,然後通過getResources().openRawResource(R.raw.文件);來得到一個InputStream對象,然後讀取文件的內容。

What is Android?



What is Android?


Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.


Features



  • Application framework enabling reuse and replacement of components
  • Dalvik virtual machine optimized for mobile devices
  • Integrated browser based on the open source WebKit engine
  • Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)
  • SQLite for structured data storage
  • Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)
  • GSM Telephony (hardware dependent)
  • Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
  • Camera, GPS, compass, and accelerometer (hardware dependent)
  • Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE

Android Architecture


The following diagram shows the major components of the Android operating system. Each section is described in more detail below.


Android System Architecture


Applications


Android will ship with a set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.


Application Framework


Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user.


Underlying all applications is a set of services and systems, including:


  • A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser
  • Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data
  • A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files
  • A Notification Manager that enables all applications to display custom alerts in the status bar
  • An Activity Manager that manages the lifecycle of applications and provides a common navigation backstack

For more details and a walkthrough of an application, see Writing an Android Application.


Libraries


Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:



  • System C library – a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices
  • Media Libraries – based on PacketVideo’s OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
  • Surface Manager – manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications
  • LibWebCore – a modern web browser engine which powers both the Android browser and an embeddable web view
  • SGL – the underlying 2D graphics engine
  • 3D libraries – an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer
  • FreeType – bitmap and vector font rendering
  • SQLite – a powerful and lightweight relational database engine available to all applications

Android Runtime


Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language.


Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included “dx” tool.


The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.


Linux Kernel


Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.