android - Can't bind an Activity to Service -


i'm having trouble getting onserviceconnected() method run, means it's not binding activity service.

it's simple i've missed out - i've tried quite few times - starting scratch.

here go...

my service class

import android.app.service; import android.content.intent; import android.os.ibinder; public class quickservice extends service { private final ibinder mbinder = new quickbinder(this); @override public ibinder onbind(intent intent) { return mbinder; } } 

my binder class

import android.os.binder; public class quickbinder extends binder { private final quickservice service; public quickbinder(quickservice service){ this.service = service; } public quickservice getservice(){ return service; } } 

and... activity trying bind service.

import android.app.activity; import android.content.componentname; import android.content.context; import android.content.intent; import android.content.serviceconnection; import android.os.bundle; import android.os.ibinder; public class quickactivity extends activity { quickservice mservice; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.activity_connecting); } @override protected void onstart() { super.onstart(); intent intent = new intent(this, quickservice.class); bindservice(intent, mconnection, context.bind_auto_create); } @override protected void onstop() { super.onstop(); // unbind service unbindservice(mconnection); } /** defines callbacks service binding, passed bindservice() */ private serviceconnection mconnection = new serviceconnection() { @override public void onserviceconnected(componentname classname, ibinder service) { logger.d("connected!!! :d"); // we've bound localservice, cast ibinder , localservice instance quickbinder binder = (quickbinder) service; mservice = binder.getservice(); } @override public void onservicedisconnected(componentname arg0) { } }; } 

also, service defined in manifest file - in case thought problem.

<service android:name=".quickservice"></service> 

so, doing wrong here? why isn't onserviceconnected() method being called?

update following

 <service android:name=".quickservice"> <intent-filter> <action android:name=".quickservice .bind" /> <category android:name="android.intent.category.default"/> </intent-filter> </service> 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -