android - Unable to start service Intent, U=0: not found -
i have been struggling 2 days on issue. have 2 apps , trying communicate messenger ipc even't failed bind server app's service.
--- server side
<service android:name="com.example.remoteservice" android:exported="true"> </service> </application>
-- client side
@override protected void oncreate(bundle savedinstancestate) { : this.connection = new remoteserviceconnection(); @override public void onstart() { : intent intent = new intent(); intent.setclassname("com.example.client", "com.example.remoteservice"); //intent = new intent("com.example.remoteservice"); //i.setpackage(this.getpackagename()); boolean ret = bindservice(intent , this.connection, context.bind_auto_create);
ret false , receives system message w/activitymanagerservice: unable start service intent { act=com.example.remoteservice pkg=com.example.client } u=0: not found
it seems ok implementation. feel it's under layer issue. please help.
thanks
here's service class
public class remoteservice extends service { private messenger messenger; //receives remote invocations @override public ibinder onbind(intent intent) { if(this.messenger == null) { synchronized(remoteservice.class) { if(this.messenger == null) { this.messenger = new messenger(new incominghandler()); } } } //return proper ibinder instance return this.messenger.getbinder(); } private class incominghandler extends handler { @override public void handlemessage(message msg) { system.out.println("*****************************************"); system.out.println("remote service invoked!!!!!!"); system.out.println("*****************************************"); int = msg.what; toast.maketext(remoteservice.this.getapplicationcontext(), "remote service invoked-("+what+")", toast.length_long).show(); //setup reply message message message = message.obtain(null, 2, 0, 0); try { //make rpc invocation messenger replyto = msg.replyto; replyto.send(message); } catch(remoteexception rme) { //show error message toast.maketext(remoteservice.this, "invocation failed!!", toast.length_long).show(); } } } }
try start service this
startservice(new intent(this, yourservice.class));
don't forgot add service in manifest,
<application> <service android:name=".myservice" > </service> </application>
Comments
Post a Comment