asynctask

Android - AsyncTask and error handling

I'm converting my code from using Handler to AsyncTask. The latter is great at what is does - async updates and handling of results in the main UI thread. What's unclear to me is how to handle exceptions if something goes haywire in AsyncTask#doInBackground? The way I do it is to leave error Handler and send message to it. It works fine ...

Android - AppWidgets, AlarmManager and AsyncTask

I'm not having much luck with updating an app widget with AlarmManager generated broadcasts. Here's what I do: Initializing AlarmManager on AppWidgetProvider#onEnabled AlarmManager alarms = (AlarmManager) context.getSystemService( Context.ALARM_SERVICE); alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemC...

AsyncTask and Contexts

So 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 ex...

How to get XML using AsyncTask and Timer?

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.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() I'm using SDK 1.5 wit...

Android AsyncTask context problem

I've been working with AsyncTasks in Android and I am dealing with a strange issue. Take a simple example, an Activity with one AsyncTask. The task on the background does not do anything spectacular, it just sleeps for 8 seconds. At the end of the AsyncTask in the onPostExecute() method I am just setting a button visibility status to V...

How to arrange long (time consuming) actions on Android?

For instance, we are in SomeActivity and the activity has a button that invokes moving files from one dir to another (let's call it job). On BlackBerry I would: push a non-cancellable popup (Dialog screen) saying "Please wait..." start a thread that fulfills the job on thread completion close the popup This approach 99.99% can guara...

I don't know when to use a Service or AsyncTask or Handler

Can someone tell me the TRUE difference? ...

I have one Activity. In this Activity, I executed a AsyncTask , but it's not working.

private class ExecuteLocations extends AsyncTask<String, Void, Void>{ private final ProgressDialog dialog = new ProgressDialog(ListProfiles.this); protected void onPreExecute() { //this.dialog.setMessage("Starting pre-execute..."); //this.dialog.show(); } @Override protected Void doInBackground(Strin...

Android Asynk Task

Hi, is a good practice to have an Asynk task with a loop like this inside? while (true) { check queue and request API Because i need to wait for my Activities and service needs to comunicate with the APi. Thanks ...

Cleanly handling AsyncTimeout on ASP.NET Async Page

According to this article The Begin Event Handler is Always Invoked The second impliciation of AsyncTimeout that I had not really internalized until recently is that the begin event handler for a registered async task is always invoked, even if the page has timed out before ASP.NET gets around to starting that task...

AsyncTask Bug on HTC Sense

Im using HTC Hero with HTS sense. Im experience that sometimes AsyncTask not will run doInBackground method on execute(); Its only on my Hero this appears. Someone have come across same problem? / Martin ...

Java Timers - Functions called not completing!

So I have a TimerTask task calling a function onTimerComplete() in its run() onTimerComplete() looks something like this: private void onTimerComplete(){ myFunc1(); myFunc2(); } I make a Timer t and I schedule the TimerTask with t.schedule(task, 2000); The problem is, when the timer is up and the task runs my onTimerComplete() b...

Fetching data (responsebody) with a HttpClient in an AsyncTask and returning the data outside the AsyncTask to the UI-thread

Basically I'm wondering how I'm able to do what I've written in the topic. I've looked through many tutorials on AsyncTask but I can't get it to work. I have a little form (EditText) that will take what the user inputs there and make it to a url query for the application to lookup and then display the results. What I think would seem t...

ProgressDialog not working in external AsyncTask

I'm beginning to think that to get a ProgressDialog to work the AsyncTask has to be an inner class within an Activity class. True? [Edited much later...the answer is False and I'm not sure if this is a bug or what. I'm using Android 1.5. I'm going to read up on Services.] I have an activity the uses a database to manipulate informati...

AsyncTask, RejectedExecutionException and Task Limit

I am fetching lots of thumbnails from a remote server and displaying them in a grid view, using AsyncTask. The problem is, my grid view displays 20 thumbnails at a time, so that creates 20 AsyncTasks and starts 20 executes, one per thumbnail. I get RejectedExecution exception in my code. I recall reading somewhere that there is a limit...

Android 1.5: Asynctask doInBackground() not called when get() method is called

Hi all, I am running into an issue with the way my asynctasks are executed. Here's the problem code: firstTask = new background().new FirstTask(context); if(firstTask.execute().get().toString().equals("1")) secondTask = new background().new SecondTask(context); What I'm doing here is creating a new asynctask object, assignin...

BitmapFactory.decodeStream returning null when options are set.

Hi! I'm having issues with BitmapFactory.decodeStream(inputStream). When using it without options, it will return an image. But when I use it with options as in .decodeStream(inputStream, null, options) it never returns Bitmaps. What I'm trying to do is to downsample a Bitmap before I actually load it to save memory. I've read some goo...

How to cancel AsyncTask when Activity finishes?

In my Activity I use multiple AsyncTask classes. How to cancel AsyncTask when Activity finishes? ...

How to handle an AsyncTask during Screen Rotation?

I read a lot on how to save my instance state or how to deal with my activity getting destroyed during screen rotation. There seem to be a lot of possibilities but I haven't figured out which one works best for retrieving results of an AsyncTask. I have some AsyncTasks that are simply started again and call the isFinishing() method of...

What's the most "death-resistant" component on Android?

I'm looking for the most suitable class to be a dispatcher for AsyncTasks invoked from my Activities. I think it could be one of these: subclass of Application; subclass of Service; my own static stuff. As for me - it's simlier to implement the 3rd choice. But the question is will it be more "death-resistant" than Service or Ap...