android - service sending string to another activity without opening it -
i have service working in background - service a. when open activity - activity a, want service change text displayed on edittext field of activity a. thought maybe if context of opened activity able use , work on views. possible?
also related question: if don't have name of field, can use loop run , search views in activity , properties?
it seems less direct method preferred getting this, rather have activity directly updated service. in fact, in general service/activity communications best handled in 1 of following ways:
- messagehandlers- basically, 1 can send message other, in turn other sets actions of text.
- broadcastreceivers (localbroadcastreceiver okay)- 1 part sends broadcast message listening, other sets listener message. intent passed, can contain message.
i suggest use second. application sends broadcast service upon opening, , service returns broadcast pass requested data activity.
see service docs android sdk.
Comments
Post a Comment