kaneda
kaneda

Reputation: 6187

Is it possible to override a method from an existing class using Dexmaker?

Is it possible to change at runtime the behaviour of a method from a class already loaded using Dexmaker, by proxing or generating code?

UPDATE

Just a remark: I want to add a method/modify existing one from my own application, not from the android framework.

Upvotes: 3

Views: 1013

Answers (1)

JesusFreke
JesusFreke

Reputation: 20282

No. It is not possible.

You could create a new class that extends the original, or possibly even make a copy of the class, with a new name and a tweaked implementation. But you can't replace an existing class.

Your best bet is probably to extract out the code that you might want to modify into a separate class, and then pass in an instance of that class to whatever uses it. And then, if you need to create a new implementation, you can subclass it and pass in the subclass instead.

Upvotes: 2

Related Questions