Activity的隐式启动,
什么都不说了,直接上代码
主要是通过配置文件中的 <intent-filter>标签来实现的
<span style="font-size:24px;"> </span><span style="font-size:18px;"><activity android:name="com.example.testbook.Second">
<intent-filter >
<action android:name="com.example.testbook.Second"/> <span style="white-space: pre;"> </span>//action启动的命令
<category android:name="CATEGORY_PREFERENCE"/><span style="white-space: pre;"> </span>//该activity的属性
</intent-filter>
</activity></span>
<span style="font-size:18px;">
</span>
<span style="font-size:24px;"><span style="white-space:pre"> </span>其中 category的各项属性值及意义</span>
<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;">CATEGORY_BROWSABLE<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;">目标activity可以使用浏览器来显示-例如图片或电子邮件消息.</span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="white-space:pre"> </span>CATEGORY_GADGET<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;">该activity可以被包含在另外一个装载小工具的activity中</span> </span></span>
</span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="white-space:pre"> </span>CATEGORY_HOME<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;">该activity显示主屏幕,也就是用户按下Home键看到的界面.</span></span></span>
</span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="white-space:pre"> </span>CATEGORY_LAUNCHER<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;">该activity可以作为一个任务的第一个activity,并且列在应用程序启动器中.</span></span></span>
</span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"> </span>CATEGORY_PREFERENCE<span style="white-space:pre"> <span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">该activity是一个选项面板.</span></span></span>
</span></span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">
</span></span></span></span></span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"> </span>启动该Activity</span></span></span></span></span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 14px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"></span></span></span></span></span></span></span></span></span><pre name="code" class="java"><span style="white-space:pre"> </span>Intent intent = new Intent("com.example.testbook.Second");<span style="white-space:pre"> </span>// 里面为启动Activity配置文件中的action属性
startActivity(intent);
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">
</span></span></span></span></span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">
</span></span></span></span></span></span></span></span>
<span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="white-space:pre"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">
</span></span></span></span></span></span></span></span>