Android :: Timing An ASyncTask

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".

Android :: Timing an ASyncTask


Android :: Timing Out An AsyncTask?

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

Android :: Instance Variable Of Activity Not Being Set OnPostExecute Of AsyncTask - Return Data From AsyncTask

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

Android :: Using AlarmManager As Timing Service

Jan 19, 2010

I wanted to ask a question regarding the Alarm Manager. I have a requirements of setting long running timers in my application. The minimum duration for my timer is 1 hour...and the maximum may be for 4-5 days. This timer is supposed to run in the background, and when it fires/expires, i have to show something on the GUI. The timer can be re-scheduled once it fires based on user action.

What is the best approach for scheduling such long running timers ?

Should i make use of the Alarm Manager ? Or will it be an overkill ? As far as i know, alarms are retained even if the device goes to sleep and they wake up the device when the alarm goes off.

I am thinking of using a simple Java TimerTask as an alternative to setting an alarm: http://java.sun.com/j2se/1.5.0/docs/api/java/util/TimerTask.html.

But i am not sure what will happen to the timer task if the device went to sleep while the task was running.

View 5 Replies View Related

Android : Get Timing Information About Key Events?

Oct 5, 2010

I'm doing my thesis work on resource management on android and I want to be able to measure the "responsiveness" of an application to figure out if the application get enough resources and is scheduled often enough.

So what I want is a way to insert timestamps on events, e.g. button clicks, when they are created and when they are consumed. This way I can get the "responsiveness" of the application. But I have a hard time of finding exactly where the events are created and also consumed.

In Handler.java there is the handleCallback(Message message) method which I can insert the end time stamp. I tried to add a long variable in the Message class and that worked well (had to rebuild the api though). So my problem is to find the place where the button click is generated and where the message that corresponds to that event is being created so I can add a time stamp.

I also welcome other suggestions on how to measure the "responsiveness" of an application or other way to measure how well an application performs.

View 2 Replies View Related

General :: Android Battery Graph Timing

Feb 29, 2012

Why the time above the adroid bat graph and the one below are different. At this moment is says on my device 1h 28 minutes on battery. Below the graph 50m 22s is shown. What is the difference between those timers ?

View 2 Replies View Related

Android :: Droid APIs That Allow App To Retrieve GSM Timing Advance?

Dec 4, 2009

Are there any Android APIs that allow the application to retrieve the GSM Timing Advance?

View 2 Replies View Related

Android :: Handler Class And The Timing Of When Its Message Queue Is Emptied

Sep 6, 2010

I was curious about the nature of the handleMessage() and sendMessage() behavior of the Handler class. I want to be able to send message to another thread in such a way that the destination thread can process the message queue when it wants to. It seems, however, that the message is processed by handleMessage() practically as soon as it's sent.

I'm trying to design a game loop thread that does something like this:

CODE:.....

However, I as soon as sendMessage() is called (from the parent/calling thread), the Handler.handleMessage() is processed (in the child/receiving thread), even if the child/receiving thread is blocking in a while loop.

I've seen this problem solved in other games by using a thread-safe list (ConcurrentLinkedQueue). The UI thread just posts events to this queue, and the game loop can remove the events as it seems fit. I just assumed the Handler class was designed for this purpose. It seems it's more intended for asynchronous callbacks to the parent thread.

View 1 Replies View Related

HTC EVO 4G :: Hotspot Timing Out When Trying To Connect / Stop It?

Jun 8, 2010

Is anyone else having issues with connections to the hotspot timing out when trying to connect or when already connected? I have tried to search around before posting but even most of my friends haven't come across this issue yet.

Trying to connect with a winxp laptop and a mac laptop. Tried open, WPA and WPA2.

View 8 Replies View Related

HTC Incredible :: New Root Method / No More SD - Card Timing

Jul 14, 2010

Closed, starting a new thread for development. Doesnt work as it stands, check out the other thread for more info

View 49 Replies View Related

HTC Desire :: Giving 8 To 9 Hour Battery Timing

Sep 21, 2010

Managing just 8-9 hrs with ny battery, and believe me I barely use the phone! Just a few calls, few texts, 5 min Internet, 5 min face book - thats it. I have everything turned off that I can turn off. Come on HTC sort it out - this is obviously by far the worst criticism you have.

View 7 Replies View Related

HTC Droid Eris :: How To Increase Bettery Timing?

May 30, 2010

I am new to the droid family. I bought the Eris Droid about 2 months ago. I wanted to be able to chat with my family, get on facebook, have directions to places my husband refuses to get directions for. A little bit of everything and the droid fits me perfectly. EXCEPT I'm really not liking the battery life. I fully charged in late yesterday, didn't use it much since and this am the battery is almost depleted. I changed some settings on my incoming mail and cleared cache. What else am I missing? I hope a stronger longer lasting battery will be forthcoming.

View 11 Replies View Related

Motorola Droid X :: Battery Timing About 14 Hours Only

Jul 16, 2010

I purchased my DX yesterday, used it for about 20 minutes then let it charge until about an hour after or more after it said it was done charging. Did I do this incorrectly? Because I only got about 14 hours worth of battery time. I was very data intensive last night.

View 5 Replies View Related

HTC EVO 4G :: Stop Screen From Timing Out During A Phone Call

Jul 6, 2010

New EVO user here as of last Friday. I've done a ton of searching, watching and reading and I have a couple questions to the experts out there.

Please let me know if there is a way to stop the screen from timing out (going dark) during a phone call. I find it annoying to have to hit the power button to get the screen back..

I'm using earbuds so the phone isn't near my face and it recognizes the phones as I can see the headset icon. I keep the phone on my desk and the screen times out almost immediately after I make a call and accept an incoming call. It's extremely annoying since I make a ton of work calls and I need to either navigate through an auto attendant and / or leave a message. All of which I have to hit the power button every single time I want the screen to turn back on. I have noticed that the volume buttons turn the screen back on as well.

The screen timeout is set at 2 minutes under the "Sound & Display" category but that doesn't effect the screen time out during a call. Anyone out there have a solution?

View 11 Replies View Related

Motorola Droid :: Stop Youtube Shutdown / Timing Out?

Nov 12, 2009

My Droid goes to sleep in the middle of my Youtube videos. Is there a way to stop it from shutting down/timing out without setting the Droids timeout to a longer time setting? I have it set for 1 min.

View 2 Replies View Related

Samsung Fascinate :: Synch Setting To Set Refresh Timing?

Sep 13, 2010

One of the supposed fixes for the lousy battery life on the Incredible was to set the Sync to every hour or two.

I thought I saw this setting on the Fascinate but can't seem to find it again. Anyone know where it is?

View 2 Replies View Related

Samsung Vibrant :: Change Timing Of Lights On Capacitive Keys?

Jul 18, 2010

Has anyone figured out how to keep the lights from going out on the capacitive keys? I can't see what I am doing at night. They go out so fast.

View 2 Replies View Related

Sprint HTC Hero : Text Messages Timing Off By 3 Min - Unique To One Contact

Jan 18, 2010

So I have a very weird yet unique case with my stock text messaging app. Just this past weekend I started noticing that one of my contacts text messages were consistently showing up 3 minutes earlier from my text to them. So every time I send a text their response shows up above it which is very annoying. This case is only occurring for this contact, everyone else shows up just fine.

Now, this is what I have determined so far...

1) It's only happening when I receive a text from someone using a DROID on Verizon. I had a another friend who I had not recently text with sent me a text message to test my theory. The issue still occurs...

2) I had my sister who is on Verizon text me on her Blackberry Tour and the timing of her text shows up correctly. So it can't be the network right?

3) 3rd party apps (Handcent/ChompSMS) don't have this issue at all, the timing is perfect for everyone so my guess is that there is something wrong with the stock messaging app?

I have a whole bunch of other text from other contacts and I don't have this issue, it's just happening to the one contact that I have...actually, now two, which both have a DROID.

I may have to commit to using Handcent but I've been testing out the stock messaging app lately to evaluate the wake time after the firmware update and just noticed this problem occurring this past weekend only. I was using the stock messaging app even before this weekend and didn't notice this problem.

View 1 Replies View Related

Android :: Threads Or ASyncTask

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

Android :: AsyncTask And Queries

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

Android :: AsyncTask On A Button

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

Android :: AsyncTask And UI Activity

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

Android :: ViewSwitcher With AsyncTask

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

Android :: How To Use AsyncTask From Thread?

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

Android :: Asynctask Threads Never End

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 its 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 wont last for the whole app running time).Is there anything Im 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

Android :: AsyncTask Not Generic

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

Android :: How To Get XML Using AsyncTask And Timer?

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

Android :: SDK1.5 - AsyncTask ?

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

Android :: AsyncTask And Contexts

Dec 16, 2009

I'm working out my first multi-threaded application using Android with the AsyncTask class. I'm trying to use it to fire off a Geocoder in a second thread, then update the UI with onPostExecute, but I keep running into an issue with the proper Context.

I kind of hobbled my way through using Contexts on the main thread, but I'm not exactly sure what the Context is or how to use it on background threads, and I haven't found any good examples on it.

Here is an excerpt of what I'm trying to do:

CODE:...........

It keeps failing at the sixth line there, because of the improper Context.

View 3 Replies View Related

Android :: Using ThreadPoolExecutor And AsyncTask

Feb 12, 2010

When using ThreadPoolExecutor can I use AsyncTask as the Runnable in my queue? Or does this defeat the purpose?

CODE:.....................

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved