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 959899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:05:52+00:00 2026-05-16T01:05:52+00:00

When I try to compile to following code, I get two errors: Description Resource

  • 0

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 <TextView, Void, Void> AsyncTask.java /AsyncTask Project/src/org/me/asynctask line 25 Java Problem

package org.me.asynctask;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import android.os.*;
public class AsyncTask extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TextView mytextview = new TextView(this);
        TextView secondtextview = new TextView(this);

        new MyAsyncClass().execute(mytextview, void, secondtextview);
    }

    private class MyAsyncClass extends AsyncTask<TextView, Void, Void> {
    protected TextView doInBackground(TextView tv)
    {
        tv.setText("Your AsyncTask was successful!");
        return tv;
    }

    protected void onPostExecute(TextView Result)
    {
        Context context = context.getApplicationContext();
        Toast mytoast = Toast.makeText(context, "AsyncTask processing complete", Toast.LENGTH_LONG);
        mytoast.show();
    }
}

Obviously AsyncTask IS a generic (http://developer.android.com/reference/android/os/AsyncTask.html#execute(Params&#8230;) so why do I get those errors?

  • 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-16T01:05:52+00:00Added an answer on May 16, 2026 at 1:05 am

    There are several problems, two of which are:

    1. You defined a class AsyncTask, which hides/collides with android.os.AsyncTask. Maybe you intended to call it AsyncTaskDemo.java or AsyncTaskActivity.java or something.

    2. You’re trying to change the UI from the background thread by calling tv.setText inside of doInBackground. That defeats the purpose of AsyncTask. Code in doInBackground shouldn’t be touching the main (or ‘UI’) thread. For mid-task updates inside of doInBackground, use AsyncTask.publishProgress.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get Compiler Error C2248 when i try to compile the following code: #include
When ever I try to compile the following code I get the error: class
If I try to compile the following C++0x code, I get an error: template<int
I have the following error when I try to compile my code in g+
When I try to compile this project I get the following error. I would
When I try to compile Gforth 0.7.0, I get the following error: $ ./configure
When I try to compile the example code given below, I get the following
Sometimes when i try to build/compile a downloaded source, i get following warning: ld:
When I try to compile the following code using System; using System.Collections.Generic; using System.Reflection;
When i try to compile the following code: #include <string.h> using namespace std; typedef

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.