Returning values from Asynctask
<p>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.</p>

<p>Would anyone be able to help me?</p>

<pre><code>private class login extends AsyncTask&lt;Integer, Void, Void&gt;{
    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);
        }
    }

}
</code></pre>
