开发者

Starting Activity and getting results from custom component

开发者 https://www.devze.com 2023-02-27 09:24 出处:网络
I\'m trying to make an advanced custom component that should be able to start an n开发者_开发技巧ew activity to allow the user to make his/her choice more easily.

I'm trying to make an advanced custom component that should be able to start an n开发者_开发技巧ew activity to allow the user to make his/her choice more easily.

Normally, you can start an activity and fetch the result by using startForResult() and onActivityResult() . But these methods aren't available in my custom component, and I have no idea how to create a hook in the onActivityResult()-function of the parent activity.

Overloading the Activity with a custom onActivityResult doesn't seem sufficient because my custom component will be used multiple times in the same Activity, and I don't see how I can know which of my custom components fired the initial request-intent..


by passing requestCode you can easily do this. just make one setter and getter for requestCode and pass unique request code in every custom class and u can achieve your task.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号