Activity的隐式启动

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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值