android应用程序,由一到多个Activity组成.每个Activity没有很紧密的联系,因为我们可以在自己的程序中调用其它Activity,特别是调用自己的代码之外生成的Activity,比如android提供的发短信或者打电话的Activity.

Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phonenumber);
        startActivity(call);
       
        Intent sms = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:"+phonenumber);
        startActivity(sms);
    从这点上看,android应用程序实际上是由多个Activity按照一定的次序拼装起来的,只不过拼装的过程中,后台传递了一些数据,使得各个Activity之间能比较好的衔接起来.
    扯了这么多,其实我的意思还是想说,android应用程序中,并没有像c++和java这样有main函数来作为应用程序的入口.android应用程序提供的是入口Activity,而非入口函数.
    在eclipse中创建一个android应用程序的时候,默认会创建一个Activity.这个Activity实际上就是入口Activity了.从哪里定义它是Activity呢?AndroidManifest.xml文件中定义了整个android应用所包含的Activity.默认生成的Activity的定义为:
        <activity android:name=".activity01" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    action节点中的android.intent.action.MAIN表明它所在的Activity是整个应用程序的入口点.而category中的android.intent.category.LAUNCHER意思是把这个Activityg归属到加载器类,即把这个Activity标注为自动会加载和启动的Activity,这样程序启动时候就先加载这个Activity了.参考手册上是这么说的----"the LAUNCHER category says that this entry point should be listed in the application launcher."意思和我理解的有出入.不过意思都是说这个Activity要被应用程序加载.
    我们可以对比下eclipse中console端输出的日志来看下.初始,我把    <category android:name="android.intent.category.LAUNCHER" />这一行在原先的xml文件中注释掉了.可以看到控制台会报错"No Launcher activity found!",实际上此时在虚拟设备上的应用程序列表中找不到"lifecycle_test"这个app,而且也没法运行,根本加载不起来.后面把注释去掉,还原到最初始的状态,然后在启动应用,可以看到"No Launcher activity found!"这部分报错信息没有了,而且虚拟设备的屏幕上,可以看到"lifecycle_test"这个app已经成功运行了.

[2011-08-11 09:29:10 - lifecycle_test] ------------------------------
[2011-08-11 09:29:10 - lifecycle_test] Android Launch!
[2011-08-11 09:29:10 - lifecycle_test] adb is running normally.
[2011-08-11 09:29:10 - lifecycle_test] No Launcher activity found!
[2011-08-11 09:29:10 - lifecycle_test] The launch will only sync the application package on the device!
[2011-08-11 09:29:10 - lifecycle_test] Performing sync
[2011-08-11 09:29:10 - lifecycle_test] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'myavd_2.2'
[2011-08-11 09:29:15 - lifecycle_test] Application already deployed. No need to reinstall.
[2011-08-11 09:29:15 - lifecycle_test] \lifecycle_test\bin\lifecycle_test.apk installed on device
[2011-08-11 09:29:15 - lifecycle_test] Done!
[2011-08-11 09:30:47 - lifecycle_test] ------------------------------
[2011-08-11 09:30:47 - lifecycle_test] Android Launch!
[2011-08-11 09:30:47 - lifecycle_test] adb is running normally.
[2011-08-11 09:30:47 - lifecycle_test] Performing test.activity.leipei.activity01 activity launch
[2011-08-11 09:30:47 - lifecycle_test] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'myavd_2.2'
[2011-08-11 09:30:47 - lifecycle_test] Uploading lifecycle_test.apk onto device 'emulator-5554'
[2011-08-11 09:30:47 - lifecycle_test] Installing lifecycle_test.apk...
[2011-08-11 09:30:54 - lifecycle_test] Success!
[2011-08-11 09:30:55 - lifecycle_test] Starting activity test.activity.leipei.activity01 on device emulator-5554
[2011-08-11 09:30:57 - lifecycle_test] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=test.activity.leipei/.activity01 }

最新文章

  1. PALIN - The Next Palindrome 对称的数
  2. MySql: 常见sql语句
  3. Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39;解决
  4. Merge Into example
  5. Oracle Form Developer: Folder FRM-99999 Error 14212
  6. 详谈easyui datagrid增删改查操作
  7. 单元测试时候使用[ClassInitialize]会该方法必须是静态的公共方法,不返回值并且应采用一个TestContext类型的参数报错的解决办法
  8. java项目使用memcache实现session共享+session基础
  9. Android:ListViewAdapter
  10. Scrapy 框架简介
  11. Ubuntu 清除缓存 apt-get命令参数
  12. &lt;pre&gt;标签的基本样式设置
  13. 实现一个函数clone,可以对JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制
  14. __Linux__操作系统发展史
  15. kafka学习之-KafkaOffsetMonitor后台监控
  16. JDBC批量执行executeBatch
  17. node+express实现文件上传功能
  18. 一次tomcat数据乱码事件
  19. IPv4协议及VLSM可变长子网划分和CIDR无类域间路由
  20. UI自动化测试框架之Selenium关键字驱动 (转)

热门文章

  1. Matlab高级教程_第一篇:Matlab基础知识提炼_04
  2. goweb-表单
  3. Codeforces1303F Number of Components
  4. Linux 进程信号量
  5. Django中间件-跨站请求伪造-django请求生命周期-Auth模块-seettings实现可插拔配置(设计思想)
  6. 前端之BOM与DOM-JQuery
  7. Codeforces 1288B - Yet Another Meme Problem
  8. Oracle不同版本中序列的注意点
  9. 二十六、linux邮件服务器
  10. RHEL安装rails后启动报错