自定义视图调用startActivityForResult [英] Custom View calling startActivityForResult

查看:700
本文介绍了自定义视图调用startActivityForResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造,我合并功能拍照定制的复合视图。

I created custom compound view where I incorporate functionality to take pictures.

我打电话像这样(从视图):

I'm calling it like this (from view):

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            ((Activity)mContext).startActivityForResult(intent, index);

这部分做工不错。我不知道该怎么做是我怎么落实

This part works good. What I don't know how to do is how do I implement

的onActivityResult

onActivityResult

在我的自定义视图?

或者我应该赶上这个活动里面,比重新路由到我的看法?看起来并不像很不错的解决方案。

Or should I catch this inside Activity and than re-route into my view? Doesn't look like very nice solution..

推荐答案

有没有办法赶上的onActivityResult 从你的观点,只能从活动

There is no way to catch onActivityResult from your view, only from Activity.

和它不是安全的假设,就是上下文对象活动。一般来说,你不应该依赖于这个事实。即使在情况下,似乎是合理的,可欣赏,你仍然应该只使用可用的方法低谷上下文接口。这是因为你不能predict上的活动所有的副作用,当你调用活动特定功能。

And its not safe to assume that's Context object is Activity. In general you should not rely on this fact. Even if it seems reasonable in case with views, you still should use only methods available trough Context interface. That's because your can't predict all side-effects on the Activity, when you're calling Activity specific functions.

这篇关于自定义视图调用startActivityForResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆