1

I am searching for a solution to update the UI from a service.

The best solution I found is this one:

subclass Application and let in-app communication go through this class

As suggested here More efficient way of updating UI from Service than intents?.

Unfortunately I am new to Android and Java programming, so I do not really understand how this works.

It would help me very much, if someone could create a working example project from the given code snippets in the solution. An app that starts a service, increases a counter and displays the counter in textview would be a good and simple example. I think I will understand this much better than a therotical solution.

Community
  • 1
  • 1
andi_s
  • 11
  • 2

1 Answers1

0

Here is an answer to a similar question where there is a full example. If you are just doing some basic background task, an AsyncTask may be a better solution though.

Community
  • 1
  • 1
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • thanks, but i need example code for the 'efficient way' - not using handlers etc. - just subclass application - this sounds much more efficient. – andi_s Mar 17 '11 at 15:05
  • That is the efficient way. It uses a Local Service so any IPC is short circuited, no aidl, etc. – Robby Pond Mar 17 '11 at 15:10
  • Well, as i said i am new to this kind of stuff, but as far as i understand the approach to subclass Application lets in-app communication go through this class. This means i could directly update the UI from the service without using any handler - this did sound very interesting, thats why i asked for an example for this solution. – andi_s Mar 17 '11 at 15:37
  • Now im very confused. How does subclassing activity have anything to do with making a service communicate with an activity? – Goku Jun 03 '13 at 16:19