Intent-意图
- 1.Intent是什么?
- 2.Intent是干什么用的?
- 3.Intent使用方法
- 4.Intent过滤器
一.Intent是什么?
官方文档是这样说的:
An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.
An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.
乌拉乌拉。。。。。。。一大堆,说的简单点,Intent的核心思想就是传递信息!那它到底是传递什么信息,给谁传递信息呢?
且往下看
二.Intent是干什么用的?
Intent是一个消息传递对象,你可以使用它从其他应用组件请求操作。尽管 Intent 可以通过多种方式促进组件之间的通信,但其基本用例主要包括以下三个:
启动 Activity:(上篇文章中有提到)
Activity 表示应用中的一个屏幕。通过将 Intent 传递给 startActivity(),您可以启动新的 Activity 实例。Intent 描述了要启动的 Activity,并携带了任何必要的数据。
如果你希望在 Activity 完成后收到结果,就调用 startActivityForResult()。在 Activity 的 onAc

522

被折叠的 条评论
为什么被折叠?



