Reputation: 37
I want to pass a function from one activity to another using Broadcasts. Like we can pass Strings and int by putExtra
, Is there a way I can pass a whole function? I know there are other ways to do this, but I need to do this with the help of broadcasts. Any help?
Ex:
void myFunc(){ /* foo */ }
Can I use myFunc
in some other activity via broadcast? I don't mind declaring the function again in the new activity as long as I get data from broadcast.
Upvotes: 0
Views: 92
Reputation: 1006744
Is there a way I can pass a whole function?
No, sorry.
Can I use myFunc in some other activity via broadcast?
No, sorry.
Alternatives:
Use one activity rather than two
Have both activities work with some other object that is outside each of those activities (e.g., a singleton serving as a repository)
Upvotes: 1