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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:56:38+00:00 2026-06-18T07:56:38+00:00

I have a AsyncTask class. I do process in AsyncTask class. But I return

  • 0

I have a AsyncTask class. I do process in AsyncTask class. But I return this class, Progress isn’t update. And I only using class, progres is update.

This is my AsyncTask class:

AsyncTaskTables.java

public class AsyncTaskTables extends AsyncTask<String, String, ArrayList<String>>{

private Context Context;

private LoginInfo AccountInfo;

private TextView ProgressStatus;
private ProgressBar ProgressValue;

public AsyncTaskTables (Context Context){
    this.Context = Context;

    AccountInfo = new LoginInfo();

    ProgressStatus = (TextView) ((Activity)Context).findViewById(R.id.tvStatus);
    ProgressValue = (ProgressBar) ((Activity)Context).findViewById(R.id.pbProgress);
}

@Override
protected void onPreExecute() {
    ProgressValue.setIndeterminate(true);
}

@Override
protected ArrayList<String> doInBackground(String... SQLCommand) {
    publishProgress("Checking Net Connection...");
    if(NetConnection()){
        try{
            publishProgress("Preparing...");

            ArrayList<String> TablesList = new ArrayList<String>();

            publishProgress("Connecting...");

            @SuppressWarnings("static-access")
            String Url = "jdbc:jtds:sqlserver://" + AccountInfo.Server + ";databaseName=" + AccountInfo.Database + "";
            String Driver = "net.sourceforge.jtds.jdbc.Driver";

            String SelectTables = "SELECT * FROM INFORMATION_SCHEMA.TABLES";

            Class.forName(Driver).newInstance();
            @SuppressWarnings("static-access")
            Connection DatabaseConnection = DriverManager.getConnection(Url, AccountInfo.UserName, AccountInfo.Password);
            Statement Command = DatabaseConnection.createStatement();

            publishProgress("Selecting tables...");
            ResultSet Results = Command.executeQuery(SelectTables);

            TablesList.clear();

            while(Results.next()){
                TablesList.add(Results.getString(3).toString());
            }

            publishProgress("Done !");

            return TablesList;
        }catch(Exception Error){
            publishProgress("Error : " + Error.toString());
            return null;
        }
    } else {
        publishProgress("Need Network Connection !");
        return null;
    }
}

@Override
protected void onProgressUpdate(String... Status) {
    ProgressStatus.setText(Status[0]);
}

@Override
protected void onPostExecute(ArrayList<String> Result) {
    ProgressValue.setIndeterminate(false);
}

@SuppressWarnings("static-access")
private boolean NetConnection() {
     ConnectivityManager NetManager = (ConnectivityManager) ((Activity)Context).getSystemService(Context.CONNECTIVITY_SERVICE);

     if (NetManager.getActiveNetworkInfo() != null && NetManager.getActiveNetworkInfo().isAvailable() && NetManager.getActiveNetworkInfo().isConnected())
         return true;
     else
         return false;
}

}

This is my MainClass:

ManagementActivity.java

public class ManagementActivity extends Activity {

private TextView Status;

private AsyncTaskTables SelectTables;

private TablesAdapter TablesAdapter = null;
private ArrayList<String> TablesList = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_management);

    Status = (TextView) findViewById(R.id.textView1);

    try {

//Problem is here...
//I am calling only "SelectTables.execute("");", progressbar is showing.
//But I am calling "SelectTables.execute("").get();", progressbar isn't showing...

        SelectTables = new AsyncTaskTables(this);
        TablesList = SelectTables.execute("").get();
        TablesAdapter = new TablesAdapter (this, R.layout.tables_row, TablesList);

        ListView Tables = (ListView) findViewById(R.id.lvTables);
        Tables.setAdapter(TablesAdapter);
        registerForContextMenu(Tables);
    } catch (Exception Error) {
        Status.setText("Error (Select Tables) : " + Error.toString());
    }

    Button btnTablesRefresh = (Button) findViewById(R.id.btnRefresh);
    btnTablesRefresh.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            try {
                SelectTables = new AsyncTaskTables(ManagementActivity.this);
                TablesList = SelectTables.execute("").get();
                TablesAdapter = new TablesAdapter (ManagementActivity.this, R.layout.tables_row, TablesList);

                ListView Tables = (ListView) findViewById(R.id.lvTables);
                Tables.setAdapter(TablesAdapter);
                registerForContextMenu(Tables);
            } catch (Exception Error) {
                Status.setText("Error (Select Tables) : " + Error.toString());
            }
        }
    });
}
}

I am calling only “SelectTables.execute(“”);”, progressbar is showing.
But I am calling “SelectTables.execute(“”).get();”, progressbar isn’t showing…

What can I do ?

  • 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-18T07:56:40+00:00Added an answer on June 18, 2026 at 7:56 am

    The Get function waits if necessary for the computation to complete, and then retrieves its result. That’s means that your UI Thread is block till your task is completed. Since your are blocking your UI thread; progress bar, will never be shown.

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

Sidebar

Related Questions

I am trying to create downloading progress. I have my class which extends AsyncTask:
I have class that extends AsyncTask class and I create instance of this class
I have this AsyncTask: private class GetMyFlights extends AsyncTask<String, Void, Integer> { private ProgressDialog
I have AsyncTask and my progress in background is in infinite loop. But I
I have a method that is executed using asyncTask with a progressdialog. After this
I have the following asynctask class which is not inside the activity. In the
i have a question regarding the AsyncTask class in android, and why it is
i have a class extends asynctask private class taskMK extends AsyncTask<Void,Void,JSONObject>{ String url; JSONObject
I have an AsyncTask with a textview loaded in the class so it looks
I have a class that extends AsyncTask , which fetches the gps cordinates from

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.