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已经成功运行了.
分享自:http://www.cnblogs.com/leipei2352/archive/2011/08/11/2135600.html