Intents and Intent Filters//意图和意图过滤器
An Intent
is a messaging object you can use to request an action from another app components. Although intents facilitate communication between components in several ways, there are three fundamental use-cases:
一个Intent是一个消息传送对象,这个对象可以让你用来请求一个行动从其它的应用组件哪里。尽管有几种方法可以用来让intent促进不同的组件之间的通讯,但是有三种基本的使用情形:
(1)To start an activity://开启一个activity
An Activity
represents a single screen in an app. You can start a new instance of an Activity
by passing an Intent
to startActivity()
. The Intent
describes the activity to start and carries any necessary data.
If you want to receive a result from the activity when it finishes, call startActivityForResult()
. Your activity receives the result as a separate Intent
object in your activity's onActivityResult()
callback. For more information, see the Activities guide.
一个activity代表一个应用里的单独的屏幕。你可以通过一个Intent的startActivity()开启一个Activity的实例。这个Intent描述了开启的这个activity并且携带了一些必须的数据。如果你想接收到这个activity的结果当这个Activity结束时,调用startActivityForResult()方法。你的activity接收到这个结果作为一个分开的Intent对象在你的activity的onActivityResult()方法里。更多的信息,参考Activities 指南。