Android :: More AsyncTask - Simultaneous Downloads
Sep 10, 2010
Implementing a service to handle connection changes and downloads. The service handles a queue of AsyncTasks, each representing a "download task". This way, we can cancel/pause tasks when connection drops, and also restore them when connection is reestablished. Since the threads AsyncTasks are run are not deterministic, how many ATs should I execute() at the same time?
I've read that I shouldn't reuse tasks. How can I achieve this pause->resume functionality then? Should I tell the thread to sleep? Should I make a no-op while if connection is down? I was trusting the cancel(true) method, which I've read is not reliable either.
My main DownloadTask is a subclass of AsyncTask that returns a new AsyncTask to be called when the connection is restored.
View 3 Replies
Jan 28, 2010
I am performing several https posts and http downloads from two different servers using AsyncTasks. The connections are fairly quick but I'm surprised to see that they are running synchronously instead of in parallel.
To be more explicit, here is pseudo-code for what's happening when I initiate a call to AsyncTask1():
CODE:..............
View 19 Replies
View Related
Jul 28, 2010
I'm trying to figure out the correct way to create an AsyncTask to retrieve some data from the internet and then to take that data and bundle it up in an Intent and pass it to a new activity(A list display). So in the first activity I just have an EditText and Button. In the event of an OnClick the task should be called and when it is finished the data should be bundled inside an Intent and passed to the next Activity. The problem is when I take the results from onPostExecute and set them to an instance variable of the main activity, that instance variable is still null when the task is complete. Here is the barebones version of the code:
CODE:...........
When I debug the application I see onPostExecute does contain a valid PlacesList full of results, so why is the instance variable places set to null after the task is executed? I am going about "returning data" from an AsyncTask incorrectly?
View 1 Replies
View Related
Dec 14, 2009
I was wondering whether Androd can catch simultaneous Key Press. For example, a application does something when a user press HOME and MENU key simultaneously. Is it a possible scenario?
View 4 Replies
View Related
Jan 28, 2009
I am working on an art project with several other people that involves simultaneity and photography. We want to coordinate a series of events involving simultaneous photographs based on the Android system.
In simple terms, here is what we are proposing. Someone writes an app for Android Phone/Camera that makes the camera take a photograph at a predetermined time so that many thousands of people all take a simultaneous photograph. The art involved here is not only the synchronizing of the event to approximate simultaneity but also making "social networking" into an element of an art project.
View 3 Replies
View Related
Jan 13, 2010
Is there a limit on the number of simultaneous http requests of the form:
HttpResponse response = client.execute(request);
I'm interested in any official limit as well as practical ones.
(In a previous life, you had to dig deep to discover that WinMo only allowed three WebRequests to be open at a time.)
Let's say I have a list of 20 files to download on a background thread.
Should I: Download them one at a time, blocking the thread (but not the UI thread) to wait for each one? Start 20 threads each downloading one of the files?
I expect the answer may be somewhere in between, where I create C threads and work on the queue of N files, where C is a number like 3 or 4.
I suspect some of you here have already done some experimentation and know the magic number. In addition, I suspect there may be more efficient ways of doing what I'm doing than creating a new DefaultHttpClient for each request.
View 10 Replies
View Related
Apr 16, 2010
With reference to this discussion, does this mean that simultaneous Record and Playback with Mediarecorder and Mediaplayer is not possible at this point?
View 3 Replies
View Related
Oct 27, 2010
I'm trying to read from a file while it still opened for witing.
View 2 Replies
View Related
Oct 10, 2010
I just installed the latest DialerOne (1.2.7.1) from the Market and find that the new simultaneous search of the call log and contacts is annoying in that it places call log entries at the top of the list, and tapping on them brings up the call history for that contact instead of listing their numbers so you can choose one to dial. I don't see any way to turn this off.Am I missing something?It would seem natural to have the ability to limit the search to the screen presented (search only the call log when the call log is displayed, or search only the contacts when contacts are displayed), but I have Dialer One display the call log by default, so that I can quickly call a recently called contact, or just start dialing to search, so this wouldn't work for me either.I would much rather go back to the way it used to be. Of course, I figured I didn't need to backup the previous version because after all, what could change? Now I have this, and the coloring of the digits on the keypad is weird, even after adjusting it as much as possible.
View 5 Replies
View Related
Oct 14, 2010
I have an android app, where in a list view for each element in list, I load an image from web in a separate thread. So if there are 8 items displayed in list view, activity will try to fire 8 different threads, one for each list item to load an image. As you scroll down the list, the number of threads may increase if the previous threads haven't finished executing.
I am curious to know how many simultaneous threads can a single android app execute in parallel? Is there a limit? I wouldn't expect these threads to cause a ANR over slow internet connection as they are independent? But it seems that ANR does happen and may be it's because app/device run low on resources, so spawning a new activity in UI takes more than 5 seconds which results in an ANR?
Any clues to how I can make responsiveness better on a slow internet connection will be appreciated.
View 2 Replies
View Related
Mar 19, 2014
I am trying to implement a functionality when i press the VOLUME DOWN and POWER BUTTON simultaneously; i must be able to run a method code inside my Activity.
public boolean onKeyUp(int keyCode, KeyEvent event)
{
}
From my initial search; it seems that only one such key press event is acknowledged at a time in Android usng the onKeyUp method. Is it true?
In my Android phone, on simultaneously pressing POWER BUTTON as well as MENU BUTTON i am able to capture a screen shot.
Does this feature not acknowledge simultaneous key presses?
View 2 Replies
View Related
Nov 25, 2010
If you don't need 3G on to do voice calls, then why would having it on not allow you to use your data connection while on a voice call?
View 9 Replies
View Related
Aug 4, 2010
I just saw a video of a Verizon guy that got FROYO already. They were showing the changes included in 2.2 and it had the option to update all the apps at the same time or something similar. I thought that was art of 2.2.
View 2 Replies
View Related
Mar 29, 2010
I probably don't need it persay...But! I want it! Just to have the peace of mind that phone calls won't interupt stuff. There have been times that I could both at the same time. Anyone think it might be implementef later? This is a real dream killer for me.
View 35 Replies
View Related
Jun 18, 2010
Is this suppose to work only with 4G or am I missing something?
View 3 Replies
View Related
Apr 1, 2010
Just started using my Desire last night! Feeling good.
However...
Was just on a call, tried to use the Android Marketplace. Couldn't. Got curious, and tried to use Google Maps mid call. Couldn't. Tried to use the internet during the call. Couldn't. Now, I'm on T-Mobile (UK) and have just come from a Nokia E71. With my E71 I could make a call and use Google Maps. Am I missing something or is this bit of multitasking somehow not possible?
View 6 Replies
View Related
Oct 19, 2009
I just wanted to check, e.g. on my Hero I can run GPS Tracker and press home and it will run in the background, play some music and press home and it will run in the background and go and do something else.
Are you saying the iPhone would have to completely exit the GPS Tracker to use another app or leave the GPS Tracker open and not do anything else for it to work?
View 4 Replies
View Related
Aug 30, 2010
How can i improve the performance of simultaneous processes agains the time and space in androied?
View 1 Replies
View Related
Apr 6, 2010
I am working on a simple application (studying purposes) which list all the files from a selected folder. On top of that I would like to have a search feature where the user can search for files (the code for that is already in place). Now, I was thinking about having the search running in the background somehow, whilst the user can still navigate, create folders, copy, sort and do other stuffs normally. When the search finishes the user would get a notification and then could click on it and go to that activity (It ideally should be the same ListView I already use for browsing the files, I would just need to update the Adapter there with the latest processed data after clicking in the notification). What's the best answer for that? Threading or AsyncTask?
View 4 Replies
View Related
Dec 27, 2009
Can anyone point me to a good example where a AsyncTask queries a local SQLite database and then updates the UI successfully. I have a database which I query using doInBackground... create a new custom SimpleCursorAdapter (overriding onViewBind), return the adapter (SimpleCursorAdapter), then in postExecute() create ListView adapter which is set to the the SimpleCursorAdapter, that was returned, then I set the listview adapter using SetAdapter(adapter);...
For some reason I throw an exception on fillWindow.java:200....
View 2 Replies
View Related
Jul 15, 2009
My application parse an xml file dans display data in a list view. On start of application i load data using an AsyncTask. A Progress Dialog is display during the load. This part works fine.A button in the application make it possible to reload the data. I would like to run the AsyncTask but the sytem say i can't alter view in other thread. I have also read an AsyncTask can't be run another time So i would like to know what is the best way to do this and not to have the "application not responding" message.
View 5 Replies
View Related
Aug 9, 2010
I know this is not how an async task should behave but my question is how to "block" the user while executing it.My need is the following: I have my own backup/restore process and I have an async task to run these two actions. The backup is fine, I can warn the user when the backup is done and that's just fine But my problem is about the restore process. When the user click on restore he shouldn't be able to make any change in the application (and anyway don't want to because he would lose all his changes).I understand that having the user blocked while restoring (or maybe with a progress bar) is not a best pratice but I do not see any other possibility in this context.
View 7 Replies
View Related
Apr 9, 2010
I know how to use AsyncTask in a standard manner to manage operations that are in the background in relation to a UI thread.However,I want to run a task in the background which might run for a very long time under certain circumstances. In these cases, I would like to force the background task to fail if it runs for an excessive amount of time.I know that I can invoke the "get(long timeout, TimeUnit unit)" method of AsyncTask in my UI thread in order to terminate my background task if it runs too long. However, in that case, my UI will block while this "get()" command is waiting.There are probably other drawbacks to directly calling "get()" in this manner, not the least of which being an evil interaction with the "done()" method of AsyncTask's contained FutureTask object, which itself is calling "get()" at least this is what I see when I look at the source code for AsyncTask.
View 10 Replies
View Related
Jul 5, 2010
I have an activity that needs to do some stuff in the background. When the background is done, I want it to load a new activity.I can successfully kick off the async task and using using ViewSwitcher I can show a nice progress dialog.However, when the user hit 'back' or 'close' from the new task, I want them to see the main screen of this task again. So, I use the showPrevious() after I start the new Activity, but I see the screen switch from the loading window back to the main window BEFORE the new Acitivity is launched.How do I get it to switch after the new activity, or when they come back from the new activity?I tried onRestart() and onResume() but both of them seem to give me a view of -1 that I couldn't do much with.
View 2 Replies
View Related
Sep 20, 2010
I'm running a network service within an ASyncTask. I want to be able to time the task, and after a certain period of time interrupt it.Is there a simple way to do this? Basically, when the doInBackground() methods starts, I want to say "If it hasn't completed in 30 seconds, do something else".
View 2 Replies
View Related
Jul 29, 2009
I'm developing a game based on SurfaceView and a game thread for the whole game thing.Now I want to do some HTTP requests triggered on events inside the thread. They should of course be asynchronous, so the game doesn't stop. I found AsyncTask to be a neat way to do this but I'm having trouble implementing this at the moment. Maybe I misunderstood the concept of AsyncTask,I don't know it just drives me nuts as I read docs and blogs and still I don't get it. So sorry if that's a dumb question but I'm mad of thinking about it.
View 4 Replies
View Related
Mar 13, 2010
while debugging and app that uses AsyncTask to record audio and update UI I noticed that everytime that an AsyncTask object ends running (finishes doInBackground and onPostExecute or on Cancelled it´s thread stays alive (running status).At least for me that should not be the behavior of the class since the doInBackground task may not stay running forever (as an example the android manual says that a status bar should be updated by an asynctask, and it won´t last for the whole app running time).Is there anything I´m missing, as a method to destroy it, or should I just ignore and keep creating threads as I need and the VM will handle them as it needs resources?
View 9 Replies
View Related
Jul 18, 2010
When I try to compile to following code, I get two errors:
Description Resource Path Location Type
Syntax error on token "void", invalid Expression AsyncTask.java /AsyncTask Project/src/org/me/asynctask line 19 Java Problem
Description Resource Path Location Type
The type AsyncTask is not generic; it cannot be parameterized with arguments AsyncTask.java /AsyncTask Project/src/org/me/asynctask line 25 Java Problem
CODE:............
Obviously AsyncTask IS a generic (http://developer.android.com/reference/android/os/AsyncTask.html#execute so why do i get those errors?
View 2 Replies
View Related
Jan 7, 2010
In order to get XML data from a server repeatedly, I'm attempting to use AsyncTask and Timer as per Mark Murphy's suggestion. I get the following error:01-07 16:11:26.705: ERROR/AndroidRuntime(729): Caused by: java.lang.Runtime Exception: Can't create handler inside thread that has not called Looper.prepare()I'm using SDK 1.5 with Eclipse on Windows.I've looked in documentation, on StackOverflow and in the Android Developers group, but I'm not clear what's causing the error or how to fix it.I can get the data once - i.e. without Async and Timer - and parse it via SAX without problems.s: I'm quite new to Android.
View 5 Replies
View Related
Apr 10, 2010
My program was going wonderfully. It is a search engine that connects to our back end database by sending Get requests to our server and displays the results. I've managed to get it to query my server and back end database, return results using JSON, return the first headers and pour them into a ListView widget in the main activity. Then when the user clicks on one of the headers it then sends another query from a sub-activity. It then parse those results and format them neatly into a WebView embedded into the sub-activity.
All this works perfectly. That is until I come to make a second query on the main activity. Listed below is my stack trace of where the error happens. I think I know why this is happening, but obviously not clearly understanding it.
I think it is because I am trying to call AsyncTask again. I remember reading that the AT can only be called once, but I presumed quite wrongly that this meant you can not do concurrent calls. I thought that once an AT had done it's task it was cleared and then could be called again, but this does not seem to be the case. Is it because of AT attempts at more than one call ? If so, would I be better changing that section into a Handler with a Runnable on the main activity?
-----Stack Trace----
CODE:.....................
View 3 Replies
View Related