comparison of Thread vs Asynctask in android?

by Hitendrasinh Gohil » Thu, 19 May 2011 14:38:16 GMT


Sponsored Links
 hi,

I have just found one google doc for ANR.i am using thread class to
retrieve data from server.and displaying it to app.

so i just want to that whether i should use Thread or should forget
the Thread because android is providing Asynctask.

can anyone elaborate this,pls?

-- 



Re: comparison of Thread vs Asynctask in android?

by Miguel Morales » Thu, 19 May 2011 14:46:42 GMT


 The only difference is that AsyncTask uses a thread pool to do its work.  If
you use a thread, you will have a slight overhead of creating and starting
the thread.  However, they both work relatively the same.

On Wed, May 18, 2011 at 11:38 PM, Hitendrasinh Gohil <







-- 
~ Jeremiah:9:23-24
Android 2D MMORPG:  http://solrpg.com/ ,
 http://www.youtube.com/user/revoltingx 

-- 


Sponsored Links


Re: comparison of Thread vs Asynctask in android?

by Saurav » Thu, 19 May 2011 14:51:48 GMT


 In my experience, (I have used both), you need to create a Hander object to
change something from the procedure that is running inside your Thread.

Whereas, if you use the AsycTask, there will be call backs to do UI
updations... I also agree with Miguel Morales.




Regards,
Saurav Mukherjee.


On Thu, May 19, 2011 at 12:08 PM, Hitendrasinh Gohil <




-- 



Re: comparison of Thread vs Asynctask in android?

by Hitendrasinh Gohil » Thu, 19 May 2011 14:55:28 GMT


 hi,

i have read this from google doc,"ANR"(Application not responding) happens
when ,

I)main thread("event thread"/"ui thread") doesnt respond to input events in
5 sec
ii)broadcast receiver doesnt finish in 10 seconds.


in my application flow is like

classA >thread>callback to classA with data>from classA activity is called

which is called the main thread in above scenario?
in this case what happens?




-- 
Regards,
Hitendrasinh Gohil

-- 



Re: comparison of Thread vs Asynctask in android?

by Miguel Morales » Thu, 19 May 2011 15:02:58 GMT


 Have you read:
 http://developer.android.com/resources/articles/painless-threading.html ? 

On Wed, May 18, 2011 at 11:55 PM, Hitendrasinh Gohil <






-- 
~ Jeremiah:9:23-24
Android 2D MMORPG:  http://solrpg.com/ ,
 http://www.youtube.com/user/revoltingx 

-- 



Re: comparison of Thread vs Asynctask in android?

by Ali Chousein » Thu, 19 May 2011 15:09:04 GMT


 Keep in mind that Asynctask is provided for finite tasks. If you need
to have a thread which should run forever, don't use Asynctask, but
use Thread.

-Ali

-- 



Re: Re: comparison of Thread vs Asynctask in android?

by Hitendrasinh Gohil » Thu, 19 May 2011 20:25:43 GMT


 hi,

i am using thread to retrieve string data from server and asynctask to
download files(avg 7 to 8mb) from server.so is it okay in this case.


-- 
Regards,
Hitendrasinh Gohil

-- 



Re: comparison of Thread vs Asynctask in android?

by Ali Chousein » Fri, 20 May 2011 13:36:06 GMT


 Using Asynctask to download files is fine I think (given that you
handle correctly the error cases; e.g. target server might be down etc
etc).


On May 19, 2:25pm, Hitendrasinh Gohil <hitendra.virtuei...@gmail.com>



-- 



Other Threads

1. Using Multiple Activities

Sorry, I know that this topic has been covered a bit. I've read
related posts and am still a bit confused. I am working on an app that
while the prototype will have 3 main screens, it will eventually have
dozens. Each screen will present either dynamically changing status or
take user input. To visualize, it is required to be laid out similar
to how MS Word or a typical PC is. It has a status bar at the top and
a navigation bar at the bottom that is common to all screens (slight
tweaks for some screens, like different icons) in the middle is what I
would call a screen layout pane that needs to be updated with an
applicable layout.

The status, nav bar, and each screen are defined in their own layout
xml file. I've created a base class for my Activities that I want to
handle updates to the status bar and handle the user clicks on the nav
bar buttons.

1. It feels right to me that each screen layout should have an
associated Activity class that understands how to control that screen.
class should be an ActivityGroup.  I can't seem to find any examples/
tutorials on how to implement that though.

2. Currently I tried making each of the screens it's own Activity and
kick that off from the main Activity by creating an Intent and than
calling startActivity.  Since its base class handle displaying the
bars the user only notices the center pane change.  The trick is that
once the main starts Activity A, I need to allow the user to navigate
to B or C by swiping left or right.  I'd rather not tightly couple the
classes so that A knows that C is left and B is right for example.
Would embedding this type of info into the base class be right?  It
doesn't feel right...

I know this has been a long post. I'd appreciate any advice.
Thanks! CB

-- 

2. Positioning a SlidingDrawer

It seems to me that per default, the ONLY thing a SlidingDrawer
provides is a fancy way of switching between to fullscreen views.

Have I missed something or can you position the drawer so it only
covers part of the screen without doing some hacks?
Right now I am setting android:topOffset to a hardcoded value which
obviously only works for my particular resolution...

(FYI I am using it for a button panel that slides up on top of a
playlist for controlling the currently playing song).

-- 

3. How to save in SIM from an Android Application?

4. enable/dissable fullscreen for lifetime of the app?

5. Why has my app disappeared from the market? Has this happened to anyone before?

6. Question on Fragmented MP4 video playback on Android Phones

7. How to dismiss the virtual keyboard