Chicowitz
Chicowitz

Reputation: 5929

pass function as an extra with Android intent

In java you can pass functions as parameters, what if you wanted to pass a function to another activity? Is this possible for example using Intent.putExtra?

Upvotes: 2

Views: 3116

Answers (1)

EJK
EJK

Reputation: 12527

"In java you can pass functions as parameters, ...". This is incorrect. Java does not support this.

You can pass an object of a particular interface and then call that interface method on the object. As long as you make this particular interface either serializable or Parcelable, then you can pass an instance of it in an intent.

Upvotes: 3

Related Questions