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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:52:21+00:00 2026-05-20T19:52:21+00:00

Okay I have been trying to get this to work for some time now.

  • 0

Okay I have been trying to get this to work for some time now. I want to be able to have my user login without having the UI hang until the server responds. When the doinbackground is complete I want it to pass an int value or perhaps a boolean value to the postexecute and then the rest of my code will execute. For some reason I have having problems passing values.

Would anyone be able to help me?

private class login extends AsyncTask<Integer, Void, Void>{
    ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "", "Loading, Please wait...", true);
    String user = "";
    @Override
    protected int doInBackground(Integer... params) {
        // TODO Auto-generated method stub
        Log.i("thread", "Doing Something...");
        int val = 0;
        if(db.userLogin(userTxt.getText().toString(), passTxt.getText().toString(), getApplicationContext()) == "No User Found, please try again!"){
            val = 0;
        }
        return val;
    }

    protected void onPreExecute(){
        //dialog.dismiss();
        Log.i("thread", "Started...");
        dialog.show();
    }
    protected void onPostExecute(int result){
        Log.i("thread", "Done...");
        dialog.dismiss();
        if(result == 0){
            toast.setText("No User Found, please try again!");
            toast.show();
        }else{
        Intent myIntent = new Intent(ctx, userInfo.class);
        myIntent.putExtra("user", user);
        startActivityForResult(myIntent, 0);
        }
    }

}
  • 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-20T19:52:21+00:00Added an answer on May 20, 2026 at 7:52 pm

    When using AsyncTask you supply 3 types.
    The first one is used to pass parameters to the background thread,
    the second one is used to pass information when publishing progress, and the third one is used to return information from the background thread to onPostExecute.

    You are currently using the first type only.

    try:

    private class login extends AsyncTask<Integer, Void, Integer>{
    

    and then

    protected void onPostExecute(Integer result){
    

    For more information, see here at the section “AsyncTask’s generic types”.

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

Sidebar

Related Questions

Okay I've been trying to figure this out for a while now. I have
Okay so I have been trying to get into IoC lately. However, I keep
Okay, I have been messing with this autocomplete stuff for 2 weeks now, and
Okay, I have this program and I don't want more than one instance of
Okay, I know this question have been asked plenty of times already, but I
Okay this one has me stumped.. mainly because i have been working on this
Okay, I've been trying to fix this for the past week or so, and
Okay, so far, I have been taking computer science courses in my high school
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay, this is just a crazy idea I have. Stack Overflow looks very structured

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.