android - Pass an Serializable object in AIDL -
i have defined aidl file
interface imyfeature { void dotask(class clazz); }
but need pass class
object process. possible in android? if so, how?
i tried:
interface imyfeature { serializable class; void dotask(class clazz); }
but doesn’t work.
aidl in android supports custom class implement parcelable
interface.
in case want send class object not possible. can send class canonical name , retrieve in service.
for example have aidl file
interface imyfeature { void dotask(string classname); }
then call :
binder.dotask(myclass.class.getcanonicalname());
and in service binder stub implementation :
private
final imyfeature mbinder = new imyfeature.stub() { public void dotask(string classname) { try { class<?> clazz = class.forname(classname); constructor<?> ctor = clazz.getconstructor((class[]) null); object object = ctor.newinstance(); } catch (exception e) { // } } };
Comments
Post a Comment