1.为什么要使用Intent?
Intent 是 Android 程序中各组件之间进行交互的一种重要方式,它不仅可以指明当前组 件想要执行的动作,还可以在不同组件之间传递数据。Intent 一般可被用于启动活动、启动 服务、以及发送广播等场景,由于服务、广播等概念
Intent分为俩种:显示Intent 和隐式Intent
1.1显示Intent
显示类型一般创建在活动中,例如跳转页面:
Intent intent = new Intent(当前页面.this, 跳转的页面.class);
startActivity(intent);
1.2隐式Intent
隐式类型一般在 AndroidManifest.xml 配置
<activity android:name=".SecondActivity" >
<intent-filter>
//<action>标签中我们指明了当前活动可以响应 com.example.activitytest.ACTION_START 这个 action
<action android:name="com.example.activitytest.ACTION_START" />
//<category>标签则包含了一些附加信息,更精确地指明了当前的活动能够响应的 Intent 中还可能带有的 category
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
//只有<act