android - Bind MemoryFile to a service fails -
i trying bind service
activity
, on bind returns memory file object created in service
.
the problem is, during onserviceconnected()
callback in activity, can receive type of object service class, except memoryfile
type object, created in service class.
the service fails bind activity when there memoryfile object.
the service class below
public class remoteservice extends service { ibinder mbinder = new localbinder(); memoryfile mfile; @override public ibinder onbind(intent intent) { // todo auto-generated method stub try { if(mfile == null) mfile = new memoryfile("mem", 1024); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } return mbinder; } public class localbinder extends binder { public memoryfile getmemoryfile() { return mfile; } } }
and inside activity, onserviceconnected()
callback happens
public void onserviceconnected(componentname name, ibinder service) { toast.maketext(mainactivity.this, "service connected", 1000).show(); mbounded = true; localbinder mlocalbinder = (localbinder)service; memoryfile = mlocalbinder.getmemoryfile(); }
Comments
Post a Comment