[android-developers] Re: service start and ui hanging
Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
Thanks for your quick response. It doesn't access any other views. It does access the context object so as to work with the sqlite dbs. On Mar 13, 10:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
Um... it sounds like you are just doing a lot of work in the main thread, and getting an ANR dialog. Don't do that. :) If you have lots of work to do, do it in a background thread. All Service callbacks happen on the main thread. On Fri, Mar 13, 2009 at 11:16 AM, Bob bshumsk...@yahoo.com wrote: Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
If you have lots of work to do, do it in a background thread. Thanks, I thought I running on a different thread by calling the service from a background thread. Have I done this incorrectly or should I not be using the context object? public void openInitialThread() { Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); } private Runnable backgroundRefresh2 = new Runnable() { public void run() { ComponentName service=_context.startService(new Intent (_context,InitialContentService.class)); } }; On Mar 13, 12:56 pm, Dianne Hackborn hack...@android.com wrote: Um... it sounds like you are just doing a lot of work in the main thread, and getting an ANR dialog. Don't do that. :) If you have lots of work to do, do it in a background thread. All Service callbacks happen on the main thread. On Fri, Mar 13, 2009 at 11:16 AM, Bob bshumsk...@yahoo.com wrote: Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
Bob wrote: Thanks, I thought I running on a different thread by calling the service from a background thread. Personally, I prefer the pattern of starting the service on the UI thread but then having the service immediately start up a background thread to do its work. That way, the service encapsulates the thread -- the client does not need to know or care what the service's threading model is. -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training in Sweden -- http://www.sotrium.com/training.php --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
startService() tells the system to start the service. The Service callbacks are still made on the main thread, as always. On Fri, Mar 13, 2009 at 12:22 PM, Bob bshumsk...@yahoo.com wrote: If you have lots of work to do, do it in a background thread. Thanks, I thought I running on a different thread by calling the service from a background thread. Have I done this incorrectly or should I not be using the context object? public void openInitialThread() { Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); } private Runnable backgroundRefresh2 = new Runnable() { public void run() { ComponentName service=_context.startService(new Intent (_context,InitialContentService.class)); } }; On Mar 13, 12:56 pm, Dianne Hackborn hack...@android.com wrote: Um... it sounds like you are just doing a lot of work in the main thread, and getting an ANR dialog. Don't do that. :) If you have lots of work to do, do it in a background thread. All Service callbacks happen on the main thread. On Fri, Mar 13, 2009 at 11:16 AM, Bob bshumsk...@yahoo.com wrote: Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
I'm sorry, I don't understand what this means. I have no callbacks. The service inserts some data into the filesystem and then exists. How do I this so the UI won't hang while the processing is going on? On Mar 13, 2:51 pm, Dianne Hackborn hack...@android.com wrote: startService() tells the system to start the service. The Service callbacks are still made on the main thread, as always. On Fri, Mar 13, 2009 at 12:22 PM, Bob bshumsk...@yahoo.com wrote: If you have lots of work to do, do it in a background thread. Thanks, I thought I running on a different thread by calling the service from a background thread. Have I done this incorrectly or should I not be using the context object? public void openInitialThread() { Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); } private Runnable backgroundRefresh2 = new Runnable() { public void run() { ComponentName service=_context.startService(new Intent (_context,InitialContentService.class)); } }; On Mar 13, 12:56 pm, Dianne Hackborn hack...@android.com wrote: Um... it sounds like you are just doing a lot of work in the main thread, and getting an ANR dialog. Don't do that. :) If you have lots of work to do, do it in a background thread. All Service callbacks happen on the main thread. On Fri, Mar 13, 2009 at 11:16 AM, Bob bshumsk...@yahoo.com wrote: Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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] Re: service start and ui hanging
All of the callback methods on Service, such as onStart(), happen in the main UI thread. If you have a long job to do, use the Thread class to do it in another thread. Semantically this is the same as the Activity callbacks. On Fri, Mar 13, 2009 at 4:48 PM, Bob bshumsk...@yahoo.com wrote: I'm sorry, I don't understand what this means. I have no callbacks. The service inserts some data into the filesystem and then exists. How do I this so the UI won't hang while the processing is going on? On Mar 13, 2:51 pm, Dianne Hackborn hack...@android.com wrote: startService() tells the system to start the service. The Service callbacks are still made on the main thread, as always. On Fri, Mar 13, 2009 at 12:22 PM, Bob bshumsk...@yahoo.com wrote: If you have lots of work to do, do it in a background thread. Thanks, I thought I running on a different thread by calling the service from a background thread. Have I done this incorrectly or should I not be using the context object? public void openInitialThread() { Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); } private Runnable backgroundRefresh2 = new Runnable() { public void run() { ComponentName service=_context.startService(new Intent (_context,InitialContentService.class)); } }; On Mar 13, 12:56 pm, Dianne Hackborn hack...@android.com wrote: Um... it sounds like you are just doing a lot of work in the main thread, and getting an ANR dialog. Don't do that. :) If you have lots of work to do, do it in a background thread. All Service callbacks happen on the main thread. On Fri, Mar 13, 2009 at 11:16 AM, Bob bshumsk...@yahoo.com wrote: Thanks, I'll look more at the logs for crash issue. But regardless of the crash, am I correct in thinking that if I call a service it should do its processing in the background and the main UI thread should immediately update? For this does it matter whether I start the service from a background thread or not? The crash doesn't occur for a while into the processing but in the mean time my UI is not progressing. On Mar 13, 11:03 am, Dianne Hackborn hack...@android.com wrote: At the very least, you should include (and look at!) the stack crawl of the crash. That will usually tell you all you need to know about why it crashed. The stack crawl is in the log. On Fri, Mar 13, 2009 at 9:39 AM, Bob bshumsk...@yahoo.com wrote: Thanks for your quick response. It doesn't access or modify any views. It accesses the context to read in some raw resources and writes to the sqllite database also via context. On Mar 13, 9:32 am, Streets Of Boston flyingdutc...@gmail.com wrote: Hi Bob, Your code snippet is not enough to give you some more info. E.g. how does backgroundRefresh2 looks like (it public void run() implementation). Based on its name 'backgroundRefresh2': does it access View-s and modify these view (e.g. update text-view, images, etc.)? If so, that may explain your crash. You should not access any View (or subclass of View) in any other thread than your main message- dispatching thread (i.e. the thread on which your onCreate/onDestroy/ onPause/onResume/onanything is called). On Mar 13, 11:05 am, Bob bshumsk...@yahoo.com wrote: Hi, I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via Thread updateThread = new Thread(null, backgroundRefresh2, new_thread); updateThread.start(); What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat. Thanks, Bob -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to
[android-developers] Re: service with a UI
Hi, The service component of my application needs to do certain tasks at some scheduled time in future. The task list itself is populated by an activity (of the same application) along with the exact date time the task should be carried out. When there are no tasks, service can stop running. Even when there are tasks, service doesn't have to run until the scheduled time of the 1st task in the (sorted) task list. Once the 1st task is taken care of, it doesn't have to run until next task's time has come. I was wondering if android has UNIX crond style process that can I make use of (programatically). Also, when new task is added or existing one is deleted, the activity needs to notify the service. I looked at AIDL but it seems to be more for communication across processes. If the service and activity are in the same process, isn't there an easier way to wakeup/notify the service that tasklist has changed ? Thanks, Sarath On Mon, Dec 29, 2008 at 4:32 PM, Mark Murphy mmur...@commonsware.com wrote: Sarath Kamisetty wrote: My application has two halves - one that interacts with the user and gathers some data and stores it, the other half of it is like service that constantly monitors and processes this data and carries out the user specified actions in the background. How do I develop this ? One approach is to split the app. into two independent parts - an activity and a service. Activity (with textboxes and buttons etc.) takes user input and stores the data in sql database. However, it is not clear to me if the service portion of the application can access it. Is that possible ? If it is the SQLite database, then all components in a single application can access the database. Here, components refer to activities, services, content providers, and intent filters. In this approach, the activity and service will be completely independent and the activity has to notify the service (somehow ?) whenever user inputs new data so that the service can reprioritize its task list. Use AIDL, static data members, or the like to communicate from the activity to the service. In this approach my app should be running in the background as soon as phone is booted up. Everybody thinks that. Then people wonder why their phones are so slow. :-( I really encourage you to think through whether your application absolutely positively must run automatically without user intervention when the phone starts up. -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training on the Ranch! -- Mar 16-20, 2009 http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ 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] Re: service with a UI
Sarath Kamisetty wrote: I was wondering if android has UNIX crond style process that can I make use of (programatically). AlarmService. Also, when new task is added or existing one is deleted, the activity needs to notify the service. I looked at AIDL but it seems to be more for communication across processes. It works within the same process as well. If the service and activity are in the same process, isn't there an easier way to wakeup/notify the service that tasklist has changed ? That depends on how you define easier. Tying an activity and a service together via static data members or the like couples them very tightly. At best, you are more likely to leak memory. At worst, you wind up in situations where the service is trying to talk to a dead activity. The developer who was trying to update a TextView from a service ran into that problem, I suspect -- updating a TextView for an activity other than the right one. So, while it may be easier to initially write the software this way, there is a good chance you will regret it later. AIDL and Intents are two means that Android offers that better decouple the activity from the service. -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training on the Ranch! -- Mar 16-20, 2009 http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ 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] Re: service with a UI
Sarath Kamisetty wrote: My application has two halves - one that interacts with the user and gathers some data and stores it, the other half of it is like service that constantly monitors and processes this data and carries out the user specified actions in the background. How do I develop this ? One approach is to split the app. into two independent parts - an activity and a service. Activity (with textboxes and buttons etc.) takes user input and stores the data in sql database. However, it is not clear to me if the service portion of the application can access it. Is that possible ? If it is the SQLite database, then all components in a single application can access the database. Here, components refer to activities, services, content providers, and intent filters. In this approach, the activity and service will be completely independent and the activity has to notify the service (somehow ?) whenever user inputs new data so that the service can reprioritize its task list. Use AIDL, static data members, or the like to communicate from the activity to the service. In this approach my app should be running in the background as soon as phone is booted up. Everybody thinks that. Then people wonder why their phones are so slow. :-( I really encourage you to think through whether your application absolutely positively must run automatically without user intervention when the phone starts up. -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training on the Ranch! -- Mar 16-20, 2009 http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---