Monday, 15 August 2011

Override and implement method at runtime in Android/Java -



Override and implement method at runtime in Android/Java -

there class which's method returns result delegate pattern.

class { interface icallback { callback(string data); } void dosomeaction(icallback cb) { //some manipuation if(cb != null) { cb.callback(response); } } }

the problem here class in library project , possible library not attached main project. so, load of class , phone call of dosomeaction should implemented reflections. how should proceed callback? read proxy, still can not understand possible solve porxy. or there other solutions such case?

i tried proxy:

class<?> clazz = class.forname("com.aa.bb.cc.dd.a$icallback"); class<?>[] interfaces = new class[] { clazz}; object proxy = proxy.newproxyinstance(clazz.getclassloader(), interfaces, handler);

in lastly line gettin "com.sun.jdi.invocationexception occurred invoking method" error.

java android reflection android-library

No comments:

Post a Comment