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 have an Activity that retrieves data from a web service. This data is
hi i am passing array of strings from activity A to Activity B. in
I'm using android 1.6 under windows 7 64bit when I call notifyDataSetChanged() from the
I am from Java Swing background. May I know why using XML to create
I would like to be able launch a 2nd Preference screen from my PreferenceActivity.
I currently have a SurfaceView (named BoardView) that is being stored in a FrameLayout.
I have followed this tutorial to use SQLite db in my android app. Since
I want to rotate my own FrameLayout in 3d in android. Do i have
I am making a media player ,who can run in background. i have to
Right now when I push a specific button it starts an intent to open

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.