java - Passing Custom Binder between packages -


how send custom binder object between android packages? service activity (in separate packages)?

i've been playing while cannot seem work.

custombinder contained in library both packages have copy of.

the error @ casting point in onserviceconnected. see "casting failed".

i've noticed bit more interesting things this. when override tostring method in custombinder, , make return string, , print out binder get, "android.os.binderproxy" instead.

updated code reflect:

package 1 (contains activity)

private serviceconnection mconnection = new serviceconnection(){      @override      public void onserviceconnected(componentname name, ibinder binder){           log.d("tag",binder.tostring());           try{                custombinder nbinder = (custombinder)binder;                log.d("tag","it worked!");           }catch(exception e){                log.d("tag","casting failed again");           }      }       @override      public void onservicedisconnect(componentname name){} }  @override public void oncreate(bundle savedinstancestate){      super.oncreate(savedinstancestate);      intent intent = new intent();      intent.setcomponent(new componentname("com.example.testservice","com.example.testservice.mainservice");           bindservice(intent, mconnection, bind_auto_create); } 

package 2 (contains service)

...

@override public onbind(intent intent){      custombinder binder = new custombinder();      return binder; } 

custombinder in library

// literally nothing public class custombinder extends binder{      @override      public string tostring(){           return "custombinder";      } } 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -