[android-developers] Re: Multiple Threads
This sounds a little bit diffecult to I'm not very experienced in writing my own ASyncTask, or creating a custum handler. Isn't it possible to create a new thread withing the asynchtask. So the big task is plitted up in several smaller tasks. On 4 mei, 16:27, Satya Komatineni satya.komatin...@gmail.com wrote: An AsyncTask may be doing its work with a single worker thread. You may want to download the sourcecode of AsyncTask and alter it so that a pool of threads can do the work to speed up. This is just thinking aloud. Or write your own handler that spawns multple threads and have the handler report back to the main thread much like the async task. Satya On Wed, May 4, 2011 at 10:03 AM, Stefan stefankru...@hotmail.com wrote: I'm making a app which got it's data from parsing a website, and I have to download around 100 webpages. This is a time consuming task, so I created a AsyncTask for downloading the data, so I can show a Loading message on the UI Thread. Only problem is, that the 100 webpages are now downloaded after each other. Is there a way to download the webpages at the same time? I tried to make a new thread in the asynctask, but I only got a Can't create handler inside thread that has not called Looper.prepare() eror... What's the best way to do this usually? -- 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 -- Satya Komatinenihttp://www.satyakomatineni.comhttp://www.androidbook.com -- 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: Multiple Threads
The problem at this moment with the app is that the retrieval of the html code from the website takes a lot of time. When you start the app at this moment, you'ill have to wait 3 minutes for loading the website. That's not very user friendly, and I guess that downloading just a little bit html cannot take such a long time. The website is sometimes also a little bit slow, so I thought that the long download time maybe is caused by the server, which needs time to react on my request. And I guess, when there are more requests at the same time to the sever (for example 10 threads). the waiting time will decrease a lot. I'm not if what I said is correct, but it sounds logically for me. On 4 mei, 17:09, TreKing treking...@gmail.com wrote: On Wed, May 4, 2011 at 9:03 AM, Stefan stefankru...@hotmail.com wrote: Only problem is, that the 100 webpages are now downloaded after each other. Is there a way to download the webpages at the same time? First question: what is the purpose of doing them all at once? --- -- 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
Re: [android-developers] Re: Multiple Threads
This isn't really an Android-specific question -- you will probably get good answers just looking for ways in Java to do concurrent HTTP requests. On Wed, May 4, 2011 at 11:22 AM, Stefan stefankru...@hotmail.com wrote: The problem at this moment with the app is that the retrieval of the html code from the website takes a lot of time. When you start the app at this moment, you'ill have to wait 3 minutes for loading the website. That's not very user friendly, and I guess that downloading just a little bit html cannot take such a long time. The website is sometimes also a little bit slow, so I thought that the long download time maybe is caused by the server, which needs time to react on my request. And I guess, when there are more requests at the same time to the sever (for example 10 threads). the waiting time will decrease a lot. I'm not if what I said is correct, but it sounds logically for me. On 4 mei, 17:09, TreKing treking...@gmail.com wrote: On Wed, May 4, 2011 at 9:03 AM, Stefan stefankru...@hotmail.com wrote: Only problem is, that the 100 webpages are now downloaded after each other. Is there a way to download the webpages at the same time? First question: what is the purpose of doing them all at once? --- -- 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 -- 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, and so won't reply to such e-mails. 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: Multiple Threads
To do concurrent HTTP request I guess threads are the way to do that? Creating a thread within a thread results here in an Can't create handler inside thread that has not called Looper.prepare()error. And I cannot find another way without multiple threads. On 4 mei, 17:27, Dianne Hackborn hack...@android.com wrote: This isn't really an Android-specific question -- you will probably get good answers just looking for ways in Java to do concurrent HTTP requests. On Wed, May 4, 2011 at 11:22 AM, Stefan stefankru...@hotmail.com wrote: The problem at this moment with the app is that the retrieval of the html code from the website takes a lot of time. When you start the app at this moment, you'ill have to wait 3 minutes for loading the website. That's not very user friendly, and I guess that downloading just a little bit html cannot take such a long time. The website is sometimes also a little bit slow, so I thought that the long download time maybe is caused by the server, which needs time to react on my request. And I guess, when there are more requests at the same time to the sever (for example 10 threads). the waiting time will decrease a lot. I'm not if what I said is correct, but it sounds logically for me. On 4 mei, 17:09, TreKing treking...@gmail.com wrote: On Wed, May 4, 2011 at 9:03 AM, Stefan stefankru...@hotmail.com wrote: Only problem is, that the 100 webpages are now downloaded after each other. Is there a way to download the webpages at the same time? First question: what is the purpose of doing them all at once? --- -- 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 -- 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, and so won't reply to such e-mails. 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: Multiple Threads
AsyncTasks are not threads. They are chunks of work (like getting a web-document) that are executed on a pool of (background) threads. Read the documentation of AsyncTask carefully. Figure out a way to have a pool of more than one background threads (happens 'automatically' for Android OS versions Donut -- Gingerbread, you need to do some extra work on Honeycomb). Then create a bunch of AsyncTasks at the same time on your UI thread (e.g. in some on() method call-back on in your onClick methods, etc) and call execute on them. Then the bunch of AsyncTasks will be executed on the pool of background threads. Be sure on implement onPostExecute to update your UI. -- 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: Multiple Threads
and once you have done all that you may notice no performance gain at all because all along the bottleneck was you phone's data connection speed... -- 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: multiple threads problem, possible memory leak
scratch that, I am simply tired for today ^) //service on destroy public void onDestroy() { handler.getLooper().quit(); } 2010/12/13 Rustam Kovhaev rkovh...@gmail.com Hello there, I have a service from which I constantly call another service(lets call it B service), the problem is that in B service I have looper which processes two Runnables and when I stop B service, thread stays running, wouldn't die and when I call B service again I have two thread already in 5 min time I have about 30 threads, thread.interrupt doesn't seem to be working -- Regards, Rustam Kovhaev http://libertadtech.com -- Regards, Rustam Kovhaev http://libertadtech.com -- 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: multiple threads problem, possible memory leak
Hi It might be the case to use a stick service and keep the thread running. Refer the SyncManager service from the AOSP email application. Hope it helps On Dec 12, 2:31 pm, Rustam Kovhaev rkovh...@gmail.com wrote: scratch that, I am simply tired for today ^) //service on destroy public void onDestroy() { handler.getLooper().quit(); } 2010/12/13 Rustam Kovhaev rkovh...@gmail.com Hello there, I have a service from which I constantly call another service(lets call it B service), the problem is that in B service I have looper which processes two Runnables and when I stop B service, thread stays running, wouldn't die and when I call B service again I have two thread already in 5 min time I have about 30 threads, thread.interrupt doesn't seem to be working -- Regards, Rustam Kovhaev http://libertadtech.com -- Regards, Rustam Kovhaevhttp://libertadtech.com -- 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