开发者

Can't bind to remote service

after calling:

result=bindService(new Intent(IUdpListenerService.class.getName()),
            serviceConnection, Context.BIND_AUTO_CREATE);

byt debugger: result return 'true'

the onServiceConnected isn't being called.

*ill mention that the remote service is installed in diffrent apk, and is being started by the command st开发者_JS百科artService(..)

Okie.. this is new thing i just found out: onServiceConnected is being triggerd, but it takes time, so what happens here.. that when i use the instance of my interface - it's still remine null, before onServiceConnected manage to be triggerd.. is that possible? –


The service needs to have an <intent-filter> with an action:

    <service android:name=".BshService">
        <intent-filter>
            <action android:name="com.commonsware.android.advservice.IScript" />
        </intent-filter>
    </service>

You can then use the action form of an Intent to bind to it:

new Intent("com.commonsware.android.advservice.IScript")

or, if your client happens to have a class or interface named IScript in the com.commonsware.android.advservice package:

new Intent(IScript.getName());


The Intent constructor you use takes an Action, not a class name. To start a certain service, use new Intent(<package context, e.g. this>, IUdpListenerService.class) instead.

Update: to start a Service or Activity in another package, use setComponent:

new Intent().setComponent(new ComponentName("com.remote", "com.remote.IUdpListenerService"));

(see this question for details)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜