How do I talk to an Activity from a Local Service in Android? -
i'm new android development , i'm confused service activity communication. need listen socket , when packet received, update in activity. i'm planning on listening socket service , want tell activity when has been received.
for want service send message activity every 5 seconds. when activity receives message prints textview.
i've looked @ (bound services) appears 1 way: activity calling methods in service. need broadcasts? aren't process process communication?
can point me in right direction? thanks.
use callback.
serviceinterface.aidl:
package com.test.service; import com.test.service.servicecallback; interface serviceinterface { /** * register callback information service. */ void registercallback(servicecallback cb); /** * remove registered callback interface. */ void unregistercallback(servicecallback cb); }
servicecallback.aidl
package com.test.service; /** * callback interface used iremoteservice send * synchronous notifications clients. note * one-way interface server not block waiting client. */ oneway interface servicecallback { /** * callback function */ void oncallback(int data); }
found link malachi's android site explaining more code.
Comments
Post a Comment