Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6039567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:23:14+00:00 2026-05-23T06:23:14+00:00

In my Activity I use a class which extends from AsyncTask and a parameter

  • 0

In my Activity I use a class which extends from AsyncTask and a parameter which is an instance of that AsyncTask. When I call mInstanceOfAT.execute("") everything is fine.
But the app crash when I press an update button which calls again the AsyncTask(In case the network job didnt work). Cause then appears an Exception which says

Cannot execute task: the task has
already been executed (a task can be
executed only once)

I have tried calling cancel(true) for the instance of the Asyctask, but it doesnt work either. The only solution so far it’s to create new instances of the Asyntask. Is that the correct way?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:23:15+00:00Added an answer on May 23, 2026 at 6:23 am

    AsyncTask instances can only be used one time.

    Instead, just call your task like new MyAsyncTask().execute("");

    From the AsyncTask API docs:

    Threading rules

    There are a few threading rules that must be followed for this class to work properly:

    • The task instance must be created on the UI thread.
    • execute(Params…) must be invoked on the UI thread.
    • Do not call onPreExecute(), onPostExecute(Result), doInBackground(Params…), onProgressUpdate(Progress…) manually.
    • The task can be executed only once (an exception will be thrown if a second execution is attempted.)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an Android activity which grabs an RSS feed from a URL, and
I have an Activity calling a Service defined in IDownloaderService.aidl: public class Downloader extends
I have an activity that has a TabHost containing a set of TabSpecs each
i have created a workflow activity that do give the item creater of a
I need to generate a list of activity from multiple tables in order of
I have a web-based application that notifies users of activity on the site via
I'm currently writing a class to handle all database-activity in my application, and so
Extends Say you're looking at the 6 basic types of UML diagram (from this
I have my own custom Content Provider that loads a database which contains the
The activity monitor in sql2k8 allows us to see the most expensive queries. Ok,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.