I created a login activity for my Android app. After the user enters the correct credentials, the login activity will switch over to the homepage but I don\'t know why my code w
Add a checker to your AsyncTask such as
// Background ASYNC Task to login by making HTTP Request 
class LoginEmployer extends AsyncTask { 
boolean validUser = false;
 Then once the user is validated inside your background task set the value to true
 if (Integer.parseInt(res) == 1) { 
      // user successfully logged in 
      // Store user details in SQLite Database 
     validUser = true;  //set valid to true
Now in postExecute check if the user is valid
protected void onPostExecute(String file_url) { 
    // dismiss the dialog once done 
    pDialog.dismiss(); 
    if ( validUser )
    {
        Intent homepage = new Intent( LoginEmployerActivity.this, 
        HomepageEmployerActivity.class); 
        // Close all views before launching Employer 
        // homePage 
         homepage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
         startActivity(homepage); 
    }