content: package com.revo.evabs;
  
  import android.annotation.SuppressLint;
  import android.app.ProgressDialog;
  import android.graphics.Typeface;
  import android.net.Uri;
  import android.os.AsyncTask;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  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 static com.revo.evabs.BadComm.CONNECTION_TIMEOUT;
  import static com.revo.evabs.BadComm.READ_TIMEOUT;
  
  public class flagcheck extends AppCompatActivity {
  
      Button submit;
      TextView resulttv;
      EditText et;
      public static final int CONNECTION_TIMEOUT = 100000;
      public static final int READ_TIMEOUT = 150000;
      String theflagtosend;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_flagcheck);
          submit = findViewById(R.id.buttonsubmit);
          resulttv = findViewById(R.id.textViewresult);
          et = findViewById(R.id.editTextflag);
  
          Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/ssb.otf");
          resulttv.setTypeface(font1);
  
          submit.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  theflagtosend = et.getText().toString();
                  checkflag(theflagtosend);
              }
          });
  
      }
  
      public void checkflag(String tosend){
  
          Toast.makeText(getApplicationContext(), tosend, Toast.LENGTH_LONG);
          new checktheflag().execute(tosend);
      }
  
      class checktheflag extends AsyncTask<String, String, String> {
  
          ProgressDialog pdLoading = new ProgressDialog(flagcheck.this);
  
          HttpURLConnection conn;
          URL url = null;
  
          @Override
          protected String doInBackground(String... strings) {
              try {
  
                  url = new URL("https://evabsflag.000webhostapp.com/flags.php");
  
              } catch (MalformedURLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                  return "exception";
              }
              try {
                  // Setup HttpURLConnection class to send and receive data from php and mysql
                  conn = (HttpURLConnection) url.openConnection();
                  conn.setReadTimeout(READ_TIMEOUT);
                  conn.setConnectTimeout(CONNECTION_TIMEOUT);
                  conn.setRequestMethod("POST");
  
                  // setDoInput and setDoOutput method depict handling of both send and receive
                  conn.setDoInput(true);
                  conn.setDoOutput(true);
  
                  // Append parameters to URL
                  Uri.Builder builder = new Uri.Builder()
                          .appendQueryParameter("flag", strings[0]);
                  String query = builder.build().getEncodedQuery();
  
                  // Open connection for sending data
                  OutputStream os = conn.getOutputStream();
                  BufferedWriter writer = new BufferedWriter(
                          new OutputStreamWriter(os, "UTF-8"));
                  writer.write(query);
                  writer.flush();
                  writer.close();
                  os.close();
                  conn.connect();
  
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                  return "exception";
              }
  
              try {
  
                  int response_code = conn.getResponseCode();
  
                  // Check if successful connection made
                  if (response_code == HttpURLConnection.HTTP_OK) {
  
                      // Read data sent from server
                      InputStream input = conn.getInputStream();
                      BufferedReader reader = new BufferedReader(new InputStreamReader(input));
                      StringBuilder result = new StringBuilder();
                      String line;
  
                      while ((line = reader.readLine()) != null) {
                          result.append(line);
                      }
  
                      // Pass data to onPostExecute method
                      return (result.toString());
  
                  } else {
  
                      return ("unsuccessful");
                  }
  
              } catch (IOException e) {
                  e.printStackTrace();
                  return "exception";
              } finally {
                  conn.disconnect();
              }
  
  
          }
  
          @SuppressLint("LongLogTag")
          @Override
          protected void onPostExecute(String result) {
  
              //this method will be running on UI thread
              //tv.setText(result);
              Log.d("Here's The soooper flaggie", result.toString());
              resulttv.setText(result.toString());
              pdLoading.dismiss();
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pdLoading.setMessage("\tLoading...");
              pdLoading.setCancelable(false);
              pdLoading.show();
  
          }
  
      }
  }
  