Thread instead of Service, is it safe ?

by Derek » Mon, 10 Nov 2008 17:26:17 GMT


Sponsored Links
 Hi,

I've an Activity A that starts a Thread T which download a file
through HTTP. It works fine. If I close my Activity (back button)
while downloading, it is destroyed (onDestroy called) but download
Thread still continue and download is completed fine.

For testing purposes I've moved my Thread T into a Service and my
Activity starts the Service now. It's a little bit complex to write
(for callbacks) but it works fine too.

What it the best approach ? From the documentation I think Service
seems better to make sure the download Thread will continue even if
the Activity is destroyed ?

Thanks.
--~--~---------~--~----~------------~-------~--~----~



Thread instead of Service, is it safe ?

by hackbod » Mon, 10 Nov 2008 18:27:31 GMT


 Correct, use a Service, your process can be killed any time after
Activity.onPause() returns if there isn't another Activity, Service,
etc active in it.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. How to use fprintf() for stdout/stderr on Android v1.1 SDK Release 1?

Hi,

I want to write simple native C application using fprintf() for stdout/
stderr, on Android emulator with v1.1 SDK Release 1.

But when I try to compile my native C application with:
~/arm-2007q3/bin/arm-none-linux-gnueabi-ld -c -lc -lm -static -o XXX
start.o main.o

I get error messages:
main.o: In function 'main':
main.c:(.text+0x188): undefiend reference to 'stdout'

As I know, Android redefines stdout/stderr, so shall I need Android
source code to compile my native C application?

Or is there any tip to use stdout/stderr in fprintf() or setvbuf() on
Android v1.1 SDK Release 1?

Many thanks,

Mars Alucard

--~--~---------~--~----~------------~-------~--~----~

2. query regarding the API for device (phone) specific data

Hi

Here my questions are

Is there any way or API or method to get the following device details
to use in my Android application?

1) Manufacturer  of the device ( phone)
2) Model or name of the device /phone
3) Firmware version
4) Original equipment (phone) manufacturer
5) Software version ( I mean manufacturer s/w version  ) is it same as
android platform version?
6) Hardware version
7) device ID as IMEI number or SIM number etc.
8) Device type like it is phone or smart phone or any other device.

also Much more hardware or software related information when needed
how android is providing such facility to applications?


Thanks and regards,
Mallikarjuna

--~--~---------~--~----~------------~-------~--~----~

3. Screen Orientation change performance Question

4. Launch my activity on click of a link

5. How ratio of dp-to-pixel change with the screen density?

6. how to use chart in application?

7. DefaultRingtonePreference in expandable list view possible ?