简体   繁体   English

如何传递和返回 Intent(相机)

[英]How to pass and return Intent (Camera)

I need something little different than usual.我需要一些与平时不同的东西。

I have like 20 buttons that can take image.我有 20 个可以拍摄图像的按钮。 I use same handler.我使用相同的处理程序。 Depending on what button clicked - I just pass "ButtonIndex" inside intent to camera.根据单击的按钮 - 我只是将意图中的“ButtonIndex”传递给相机。 I would like to get that value back in OnActivityResult so I know what to process.我想在 OnActivityResult 中取回该值,以便我知道要处理什么。

Is that possible?那可能吗? I tried to read from returned intent but value get's lost.我试图从返回的意图中读取,但值丢失了。

Yep.是的。 You can use startActivityForResult (Intent intent, int requestCode) The requestcode will be returned when the activity exits.可以使用startActivityForResult (Intent intent, int requestCode)活动退出时返回请求码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM