startActivityForResult
时间: 2024-01-09 15:07:41 浏览: 52
StartActivityForResult
startActivityForResult is a method in Android that launches a new activity and expects a result back from it. It is used when one activity wants to start another activity and get data back from it. The calling activity passes an intent to the new activity and specifies a unique request code that identifies the result. When the new activity finishes, it returns a result code and any data back to the calling activity using setResult() method. The calling activity then receives the result in the onActivityResult() method, which allows it to perform further actions based on the returned data.
For example, a camera application may use startActivityForResult to launch the camera application, and once the user takes a photo, the camera application returns the photo to the calling activity. The calling activity can then display the photo to the user.
阅读全文