tags:

views:

42

answers:

2

Hi,

I open a new thread to talk about my problem :-) , I have problems with communication between "service" to the "Activity"

what I have: I have a FTP download of a file that is downloaded in the background as a service! In the end I had a time X in a variable. furthermore it is checked whether the file is also fully load , I make it with a simple comparison of the data size.

So I have a time 0s "start time" 12:22:00 up as 20sec is "end time" 12:22:20 and a download size of 0Kb goes to 5000kb.

These values are defined in the service.

Project:

I want to show this graphically or via text in the GUI of the activity .

like this:

File Download time: X seconds X seconds, will be scanned progressively and dynamically displayed. 1. sec, 2 sec ...... 20 sec

Download traffic: X kb of 5000 kb

Download rate is to be displayed: 0kb, 250 kb, 500 kb ..... 5000 kb.

Now my question:

how do I do that, which transfers the service these values to the activity! and how can I display in the activity "dynamically and automatically."

I thank you all for your efforts

+1  A: 

Send a broadcast Intent with the data via sendBroadcast(), that the activity picks up with a BroadcastReceiver. Here is a sample project from one of my books demonstrating this.

CommonsWare
Specifically, look at line 225 of WeatherPlusService.java ("broadcast" is declared at the top) and lines 113-117 of WeatherPlus.java. Be sure to register and unregister the BroadcastReceiver in your Activity's onPause() and onResume() handlers. You can add any data you want to pass in the Intent's Bundle. That's all you need to do.
Andrew
A: 

many thanks , the sample project is not working on my system, do you have any simplier and easier example code for me