Intents

  An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use-cases:

 Intent用来封装各组件跳转时的数据,行为,目标组件等信息的类。通常有下面3个功能:
  • To start an 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.

  • To start a service: 

A Service is a component that performs operations in the background without a user interface. You can start a service to perform a one-time operation (such as download a file) by passing an Intent to startService(). The Intent describes the service to start and carries any necessary data.

If the service is designed with a client-server interface, you can bind to the service from another component by passing an Intent to bindService(). For more information, see the Services guide.

  • To deliver a broadcast: 

  A broadcast is a message that any app can receive. The system delivers various broadcasts for system events, such as when the system boots up or the device starts charging. You can deliver a broadcast to other apps by passing an Intent to sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().

 

  注意:没有ContentProvider

 

相关文章:

  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-09-18
  • 2021-10-11
  • 2022-12-23
  • 2022-03-09
猜你喜欢
  • 2021-06-03
  • 2022-01-18
  • 2021-06-17
  • 2022-12-23
  • 2021-06-21
  • 2021-12-05
  • 2022-01-04
相关资源
相似解决方案