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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:08:49+00:00 2026-06-03T01:08:49+00:00

I am using AsyncTask as an inner class with the following signature as below:

  • 0

I am using AsyncTask as an inner class with the following signature as below:


public abstract class BaseFragmentActivity extends FragmentActivity {
    static final int PROGRESS_DIALOG = 0;
    Dialog progessDialog;

public abstract void displayData(T output);

@Override
protected Dialog onCreateDialog(int id) {
    if (id == PROGRESS_DIALOG) {
        ProgressDialog progressDialog = ProgressDialog.show(this, "",
                "Loading. Please wait...", true);
        progessDialog = progressDialog;
    }

    return progessDialog;
}

class PerformOPTask<T> extends AsyncTask<Void, String, T> {
    // connector=new JSONConnector();
    Connector connector;
    String curUrl;
    Class<T> clazz;

    PerformOPTask(String url, Class<T> curClazz) {
        //connector = new UnitTestConnector();
        connector = new JSONConnector();
        curUrl = url;
        clazz = curClazz;
    }

    @Override
    protected T doInBackground(Void... params) {

        return connector.getData(URLUtils.getFormattedUrl(curUrl),clazz);
    }

    @Override
    protected void onPostExecute(T output) {
        displayData(output);

    }
}

}

public abstract class BaseListFragmentActivity extends BaseFragmentActivity implements OnItemClickListener, OnClickListener{

protected ListView mList;


/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.table_list);
    CommonUtil.getActionBarWithBackButton(this,getLayoutInflater());
    mList=(ListView)findViewById(R.id.table_list_listView);
    mList.setOnItemClickListener(this);

}

public void onBackABButtonPressed(View view) {
    finish();
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}

@Override
public abstract void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3);

}

public class ListAccountsActivity extends BaseListFragmentActivity {

protected Acct[] mItems;
private String[] mIcons;
protected boolean displayHandledBySubClass=false;


/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Create an array of Strings, that will be put to our ListActivity
    // Log.i("MY INFO",this.runJSONParser().getAcct().toString());
    AccountData actData = new AccountData();
    //actData=(AccountData)
    new PerformOPTask<AccountData>(getString(R.string.get_account),AccountData.class).execute();
    showDialog(PROGRESS_DIALOG);
    //.getData(URLUtils.getFormattedUrl(getString(R.string.get_account)),actData);




}

@Override
public void onItemClick(AdapterView<?> lv, View view, int position, long id) {
    // super.onListItemClick(l, v, position, id);
    // Get the item that was clicked
    Acct account = (Acct) mList.getAdapter().getItem(position);
    Intent intent=new Intent(this,AccountDetailViewActivity.class);
    intent.putExtra("selectedAccount",account);
    startActivity(intent);
}

@Override
**public void displayData(ServerOutput output){**  //error here


    if(displayHandledBySubClass){
        //handle display in subclass
        handleDisplayData(output);
    }
    else {
        Acct[] accountArray = new Acct[((AccountData)output).getAccount().size()];
        mItems = ((AccountData)output).getAccount().toArray(accountArray);
        IWMArrayAdapter<Acct> adapter = new IWMArrayAdapter<Acct>(this, mItems);
        adapter.setIcons(mIcons);
        adapter.setArrowNeeded();
        //mList is superClassVariable
        mList.setAdapter(adapter);
        dismissDialog(PROGRESS_DIALOG);
        adapter.notifyDataSetChanged();
    }
}

public void handleDisplayData(SrOutput output){

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Toast.makeText(this, "Tapped search", Toast.LENGTH_SHORT).show();
    super.onCreateOptionsMenu(menu);
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.list_servers_menu, menu);

    // Calling super after populating the menu is necessary here to ensure
    // that the
    // action bar helpers have a chance to handle this event.
    return true;
}

}

I have the following method signature for my calback method displayData in the outer class

public abstract <T> void displayData(T output);

Now I want to extend my outer class and implement displaydata method differently for extended classes based on the type of response object I am expecting.

When I define a method as below in subclass I am getting error as not a valid override:

@Override
public void displayData(ServerOutput output){}

Asynctask is invoked as :

new PerformOPTask<AccountData>(getString(R.string.get_account),AccountData.class).execute();

What is the correct way to do this. I am new to generics stuff so I am a little bit confused about all this. Thanks in advance for any help.

  • 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-06-03T01:08:50+00:00Added an answer on June 3, 2026 at 1:08 am

    Make this change to your code.

    public abstract class BaseFragmentActivity<T> extends FragmentActivity{
    public abstract void displayData(T output);
    
    class PerformOPTask extends AsyncTask<Void, String, T>
    
    
    
    
    /* ListAccountsActivity*/
    public class ListAccountsActivity extends BaseListFragmentActivity<ServerOut> {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to design a helper class that implements methods using AsyncTask. public
In my activity, I have a inner class called A extends AsyncTask . I
I am using AsyncTask and want to use getApplication() to work with class Application.
I have a common class say for eg Class A which extends AsyncTask and
I do have a problem working with my application. I am using AsyncTask class
I'm using AsyncTask class to execute WS methods. I would like to have a
I’m using AsyncTask to load bitmaps in the background. I created a class Mybackground
I was using AsyncTask class... My objective is to have a list and when
I am trying to create HTTP connection using AsyncTask class. Is it possible to
I am using AsyncTask class and as soon as i start the app I

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.