Custom View calling startActivityForResult

Viewed 12561

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 inside my custom view?

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

6 Answers

Just make the same method inside your custom view And inside the activitys onActivityResult call yourView.onActivityResult(...) and process the result inside your view.. Also as guys mentioned you must not always end up with Context being of Activity class. Usually when it is from inflated view. But if you construct your view only in code and always use the activity instance you are good.

Related