Reputation: 2220
I have two activities, Activity A has a button "Load image" which should let the user select an image, but I want to process the chosen image on an other activity B.
I think this is a common scenario, how should I handle the activity flow??
This is what I came so far(which I don't like)
Activity A--> Gallery --> Activity A --> Activity B
Activity A's onActivityResult() only gets the URI and starts Activity B, so It kind of a waste to recreate the activity just to execute 5 lines and be destroyed (insn't it?). I would like something cleaner or more direct. This is just an example, anything is welcome:
Activity A--> Gallery --> Activity B
EDIT
What about this?
Activity A--> Activity B--> Gallery--> Activity B
Is it a better approach or is it the same thing? I mean, will i gain something (performance, cleanness).
EDIT 2
As @Gaurav said, a workaround option would be to use 2 layouts instead of 2 activities thus no need to directly deal with my problem. I must say this should do for me as activity A is very thin. But for the sake of knowledge, i will welcome a "direct" answer to my question.
EDIT 3
Finally, having both layouts in the same activity didn't work (though it was a very attractive solution). My Activity B is based on libgdx (opengl), and i'm getting some nasty deadlocks when onDrawFrame is not called. So to avoid future untraceable bugs of this kind, I'll separate my activities. I'm going for Edit-1 solution, any comments would be appreciated.
Upvotes: 1
Views: 271
Reputation: 732
I think there is no other way than to call Activity B in the onActivityResult of A.
Upvotes: 1