[android-developers] Re: Thread started inside Service is killed?

2012-03-22 Thread svl
Thanks for the reply TreKing.

Actually I now tried to use startForeground().
Notification icon is hanging in the bar, but whenever I send an intent
to a Service it doesnt seem to receive it, does it mean its dead?


On Mar 19, 6:30 am, TreKing treking...@gmail.com wrote:
 On Sun, Mar 18, 2012 at 3:44 PM, svl s.i.vladimi...@googlemail.com wrote:
  The question is - how i can make sure that the thread keeps running?

 You can't, not without any guarantee.

   Another solution was to do it with a handler and run the read from
  serial port every second. Unfortunately that blocked the whole
  application and it was hanging.

 Were you running in the UI thread?

Is there a UI thread on Service? I just created a Runnable in
onStartCommand and called handlers postInTheQueue to execute runnable.


   So basically i need to make service that constantly reads from serial
  port.

 Use IntentService and don't try to run for 10 minutes straight. Or set it
 up such that you can recover and continue from where you were if you are
 killed (the OS will try to restart your Service to let it run to completion
 if it had to kill it, if you return the correct STICKY flag).

Whats the difference between Sevice and IntentService?
I do return STICKY


 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Thread started inside Service is killed?

2012-03-18 Thread svl
Hi,

I created a service to read information from the serial port. I start
a thread that actually does all the reading from the serial port. It
runs for about 10 minutes and then it just stops. No exceptions
thrown, no errors on logcat.

The question is - how i can make sure that the thread keeps running?

Another solution was to do it with a handler and run the read from
serial port every second. Unfortunately that blocked the whole
application and it was hanging.
I do create a WakeLock on service create, so it doesnt stop because of
device being locked.

If someone has any idea how to make it work Id be very greatful.

So basically i need to make service that constantly reads from serial
port.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en