title: How to start new activity after login success in Android?
body: <p>I need to start new activity after login success. I don't know the code for starting activity from one to another and how to do it in this code below, i have code for that thing is here, in these it is code for background workers.java and we have two panel :</p>
  
  <pre><code>package com.example.androidphp2016;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.Intent;
  import android.os.AsyncTask;
  
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLEncoder;
  
  public class BackgroundWorker extends AsyncTask&lt;String,Void,String&gt; {
      Context context;
      AlertDialog alertDialog;
      BackgroundWorker (Context ctx) {
          context = ctx;
      }
      @Override
      protected String doInBackground(String... params) {
          String type = params[0];
          String login_url1="http://adminlogin.php";
          String login_url2="http://studentlogin.php";
          if(type.equals("login1")) {
              try {
                  String user_name = params[1];
                  String password = params[2];
                  URL url = new URL(login_url1);
                  HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
                  httpURLConnection.setRequestMethod("POST");
                  httpURLConnection.setDoOutput(true);
                  httpURLConnection.setDoInput(true);
                  OutputStream outputStream = httpURLConnection.getOutputStream();
                  BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                  String post_data = URLEncoder.encode("user_name","UTF-8")+"="+URLEncoder.encode(user_name,"UTF-8")+"&amp;"
                          +URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
                  bufferedWriter.write(post_data);
                  bufferedWriter.flush();
                  bufferedWriter.close();
                  outputStream.close();
                  InputStream inputStream = httpURLConnection.getInputStream();
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
                  String result="";
                  String line="";
                  while((line = bufferedReader.readLine())!= null) {
                      result += line;
                  }
                  bufferedReader.close();
                  inputStream.close();
                  httpURLConnection.disconnect();
                  return result;
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          if(type.equals("login2")) {
              try {
                  String user_name = params[1];
                  String password = params[2];
                  URL url = new URL(login_url2);
                  HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
                  httpURLConnection.setRequestMethod("POST");
                  httpURLConnection.setDoOutput(true);
                  httpURLConnection.setDoInput(true);
                  OutputStream outputStream = httpURLConnection.getOutputStream();
                  BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                  String post_data = URLEncoder.encode("user_name","UTF-8")+"="+URLEncoder.encode(user_name,"UTF-8")+"&amp;"
                          +URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
                  bufferedWriter.write(post_data);
                  bufferedWriter.flush();
                  bufferedWriter.close();
                  outputStream.close();
                  InputStream inputStream = httpURLConnection.getInputStream();
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
                  String result="";
                  String line="";
                  while((line = bufferedReader.readLine())!= null) {
                      result += line;
                  }
                  bufferedReader.close();
                  inputStream.close();
                  httpURLConnection.disconnect();
                  return result;
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return null;
      }
  
      @Override
      protected void onPreExecute() {
          alertDialog = new AlertDialog.Builder(context).create();
          alertDialog.setTitle("Login Status");
      }
  
      @Override
      protected void onPostExecute(String result) {
          alertDialog.setMessage(result);
          alertDialog.show();
  
      }
  
      @Override
      protected void onProgressUpdate(Void... values) {
          super.onProgressUpdate(values);
      }
  }
  </code></pre>