본문 바로가기

Android

안드로이드 통신하기 HttpURLConnection / PHP(우분투/ubuntu)

* SignUp.java

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class SignUp extends AppCompatActivity {
    String IP_ADDRESS = "접속할php아이피";
    String TAG = "PHP_Test";
    EditText signup_userId, signup_password, signup_email, signup_password_ch, signup_usernickname, signup_email_ch;
    TextView signup_server_response;
    Button signup_plusbutton;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b_signup);
        signup_userId = (EditText) findViewById(R.id.signup_userId);
        signup_password = (EditText) findViewById(R.id.signup_password);
        signup_email = (EditText) findViewById(R.id.signup_email);
        signup_password_ch = findViewById(R.id.signup_password_ch);
        signup_usernickname = findViewById(R.id.signup_usernickname);
        signup_server_response = findViewById(R.id.signup_server_response);
        signup_server_response.setMovementMethod(new ScrollingMovementMethod());
        signup_plusbutton = (Button) findViewById(R.id.signup_plusbutton);
        signup_email_ch = findViewById(R.id.signup_email_ch);

        signup_plusbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String sendId = signup_userId.getText().toString(); // 아이디 입력 값을 받습니다.
                String sendPassword = signup_password.getText().toString(); // 패스워드 입력 값을 받습니다.
                String sendPassword_ch = signup_password_ch.getText().toString(); // 패스워드 재확인 입력값을 받습니다.
                String sendEmail = signup_email.getText().toString(); // 이메일 입력값을 받습니다.
                String sendEmail_ch = signup_email_ch.getText().toString(); // 이메일 인증번호 값을 받습니다.
                String sendNickname = signup_usernickname.getText().toString(); // 닉네임값을 받습니다.

                InsertData task = new InsertData(); //inserData 클래스 객체를 선언해서 사용합니다.
                /**
                 * task execute를 사용해서 AsysncTask를 실행하면서 매개변수를 넣어 줍니다
                 * 첫번째 [0번 인덱스] 는 아이피주소 두번째 [1번 인덱스] 는 아이디, 2번 인덱스는 패스워드, 3번 인덱스는 이메일 을 매개변수를 넣습니다.
                 * 비동기 AsysncTask 의 실행 패턴은
                 * 실행(execute) -> 백그라운드 작업(doinBackground) [백그라운드 스레드에서 비동기 작업 시작]
                 *  -> 진행상황 업데이트(onProgressUpdate) 백그라운드 스레드 진행상황 메인 스레드 전달-> 비동기 실행 완료 후 처리(onPostExecute) 메인스레드에 완료상태 전달
                 */

                check_Signup();
                // 클라이언트 (안드로이드에서) 유효성검사를 한번 실시합니다.
                task.execute("http://" + IP_ADDRESS + "/signup.php", sendId, sendPassword, sendEmail, sendNickname, sendPassword_ch, sendEmail_ch);
                // execute() 를 통해 AsyncTask를 실행합니다, dolnBackGround 함수의 파라미터로 작용합니다
                Log.d(TAG, "onClick: 여기가 제일 마지막?ㅁㄴㅇ");

            }
        });
    }

    public void check_Signup() {


    }

    class InsertData extends AsyncTask<String, Void, String> {
        // AsyncTask를 상속해서 백그라운드에 실행될 작업을 정의하는 insertData클래스입니다.
        ProgressBar progressBar;

        // 프로그레스바 변수를 선언합니다.
        @Override
        protected void onPreExecute() {
            // 백그라운드 작업이 실행되기 전에 호출되는 메서드 입니다.
            super.onPreExecute();
            // 부모 클래스의 execute메서드를 호출합니다.
            progressBar = (ProgressBar) findViewById(R.id.singup_progressBar);
            // 프로그레스 다이얼로그를 표시하기 위해 bar를 초기화 하고 화면에 보여줍니다.
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            progressBar.setVisibility(View.INVISIBLE);
            // 작업이 완료되면 프로그래스 바를 숨깁니다.
//            signup_server_response.setText(result);
            // 서버에서 응답받은 화면을 표시하고 로그에 표시합니다.
            Log.d(TAG, "POST response 서버 에서 반응 : " + result);
            AlertDialog.Builder builder = new AlertDialog.Builder(SignUp.this);

            if (result.equals("새로운 사용자를 추가했습니다.")) {
                builder.setTitle("회원가입 확인창").setMessage(result);
                builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        intent = new Intent(SignUp.this, Home_All.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        signup_userId.setText("");
                        signup_password.setText("");
                        signup_password_ch.setText("");
                        signup_email.setText("");
                        signup_usernickname.setText("");
                        signup_email_ch.setText("");
                        startActivity(intent);
                    }
                });
            } else {
                builder.setTitle("회원가입 확인창").setMessage(result);
                builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
            }
            AlertDialog alertDialog = builder.create();
            alertDialog.show();
        }

        @Override
        protected String doInBackground(String... params) {

            String serverURL = (String) params[0];
            // 백그라운드에서 실행 될 첫 번째 파라미터인 서버 URL을 가져옵니다.
            String sendId = (String) params[1];
            // 백그라운드에서 실행 될 두 번째 파라미터인 아이디를 가져오고
            String sendPassword = (String) params[2];
            // 백그라운드에서 실행 될 세 번째 파라미터인 패스워드를 가져오고
            String sendEmail = (String) params[3];
            // 백그라운드에서 실행 될 네 번째 파라미터인 이메일을 가져옵니다.
            String sendNickname = (String) params[4];
            // 백그라운드에서 실행 될 다섯 번째 파라미터인 닉네임을 가져옵니다.
            String sendPassword_ch = (String) params[5];
            // 백그라운드에서 실행 될 여섯 번째 파라미터인 재 확인 패스워드를 가져옵니다.
            String sendEmail_ch = (String) params[6];
            // 백그라운드에서 실행 될 일곱 번째 파라미터인 이메일 인증번호를 가져옵니다.

            String postParameters = "sendId=" + sendId + "&sendPassword=" + sendPassword + "&sendEmail=" + sendEmail + "&sendNickname=" + sendNickname
                    + "&sendPassword_ch=" + sendPassword_ch + "&sendEmail_ch=" + sendEmail_ch;
            Log.d(TAG, "postParameters : " + postParameters);
            try {
                URL url = new URL(serverURL);
                // 서버 ULR을 사용해서 객체를 생성합니다.
                HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
                // 서버 연결을 위해 HttpURLConnection 객체를 생성하고 서버와의 연결을 설정합니다.
                httpURLConnection.setReadTimeout(5000);
                // 읽기 시간을 제한합니다 서버로부터 응답을 기다리는 최대 시간입니다.
                httpURLConnection.setConnectTimeout(5000);
                // 접속 시간을 제한합니다 서버로부터 접속시간을 기다리는 최대 시간입니다.
                httpURLConnection.setRequestMethod("POST");
                // HTTP 전송시 보낼 타입을 정합니다 php 에서 배운 GET , POST
                httpURLConnection.connect();
                // 서버와 연결을 합니다.
                /**
                 * Stream 이란 흐르는 시냇물 등의 의미로 일반적으로 연속적인 데이터의 흐름을 뜻합니다.
                 * 프로그램에서 외부의 데이터를 읽거나 보내기 위한 통로로 사용합니다.
                 */
                OutputStream outputStream = httpURLConnection.getOutputStream();
                // 서버로 데이터를 보낼 OutputStrem 객체를 생성합니다.
                outputStream.write(postParameters.getBytes("UTF-8"));
                // Post 방식으로 서버에 전송할 데이터를 UTF-8 문자열로 반환하여 출력 스트림을 통해서 서버로 전송합니다.
                outputStream.flush();
                outputStream.close();
                // 출력 스트림을 닫습니다.

                int responseStatusCode = httpURLConnection.getResponseCode();
                // HttpURLConnection 기능중 서버로 부터 온 코드를 수신 할 수 있습니다 이를 int로 받는 변수를 만들었습니다
                Log.d(TAG, "POST response 서버 에서 온 응답 코드 code : " + responseStatusCode);

                InputStream inputStream;
                /**
                 * InputStream 두 가지의 특징이 있습니다
                 *  1. 입력받은 데이터는 int형으로 저장되며 이는 10진수의 UTF-16 값으로 저장이 됩니다
                 *  2. 1byte로만 읽습니다
                 *  이러한 문제로 해결하기 위해 확장된 것이 InputStreamReader 입니다.
                 *  1. InputStream을 문자단위 (character) 데이터로 변환 하는 역할을 합니다.
                 *  2. byte -> character 단위로 데이터를 처리 할 수 있도로 변환.
                 *  3. char 배열로 데이터를 받을 수 있습니다.
                 */
                if (responseStatusCode == HttpURLConnection.HTTP_OK) {
                    // 서버의 응답 코드에 따라 inputStream 을 설정합니다. Http_ok 경우 성공 InputSteam을 가져 오고
                    inputStream = httpURLConnection.getInputStream();
                    Log.d(TAG, "HttpURLConnection.HTTP_OK : " + HttpURLConnection.HTTP_OK);

                } else {
                    // 그렇지 않은 경우는 응답 에러의 스트림을 출력합니다.
                    inputStream = httpURLConnection.getErrorStream();
                }

                InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
                // char형태로 변환하기 위해 inputStreamReader을 선언하고 매개 변수로 담습니다.
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                // buffer은 입력받은 문자열을 쌓아둔 뒤 한 번에 '문자열'처럼 출력합니다.
                /**
                 * String 객체와 String 객체를 더하는 행위는 메모리 할당과 메모리 해제를 발생시켜 더하는 연산이 많아지면 성능적으로 좋지 않게됩니다
                 * StringBuilder 는 문자열을 더 할때 새로운 객체를 만들어서 하는 것이 아닌 기존의 데이터에서 더하는 방식을 사용하기 때문에 속도도 빠르며 상대적으로
                 * 부하가 적습니다. 긴 문자열을 더하는 상황이 발생 할 경우 StringBuilder,Buffer 을 사용하면 좋다
                 */
                StringBuilder sb = new StringBuilder();
                // 문자열을 더하기 위해서 빌더객체를 선언합니다
                String line = null;

                while ((line = bufferedReader.readLine()) != null) {
                    sb.append(line);
                    // readLine() 메소드를 사용하면 한 줄 전체를 읽기에 String 으로 받을 수 있다.
                }
                bufferedReader.close();
                // 입력받은 문자열을 쌓아둔 뒤 한번에 문자열 처럼 출력하게 하는 Reader을 닫습니다.
                Log.d(TAG, "doInBackground: sb.toString() : " + sb);
                return sb.toString();
                // 문자열을 반환합니다.

            } catch (Exception e) {
                Log.d(TAG, "InsertData: Error ", e);
                return new String("Error: " + e.getMessage());
            }

        }
    }
}​

 

b_signup.xml  / imageview의 사진은 원하는걸로 대체 하시면 됩니다.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Login">


    <EditText
        android:id="@+id/signup_userId"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="사용할 아이디를 입력하세요"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView2"
        app:layout_constraintTop_toBottomOf="@+id/textView2" />

    <EditText
        android:id="@+id/signup_password"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="사용할 비밀번호를 입력하세요"
        android:inputType="textPassword"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView7"
        app:layout_constraintTop_toBottomOf="@+id/textView7" />

    <EditText
        android:id="@+id/signup_password_ch"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="비밀번호를 한번 더 입력하세요"
        android:inputType="textPassword"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView11"
        app:layout_constraintTop_toBottomOf="@+id/textView11" />

    <EditText
        android:id="@+id/signup_email"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="인증할 이메일을 입력하세요"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView12"
        app:layout_constraintTop_toBottomOf="@+id/textView12" />

    <EditText
        android:id="@+id/signup_email_ch"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="이메일 인증번호를 입력하세요"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView15"
        app:layout_constraintTop_toBottomOf="@+id/textView15" />

    <EditText
        android:id="@+id/signup_usernickname"
        android:layout_width="370dp"
        android:layout_height="45dp"
        android:layout_marginTop="8dp"
        android:hint="사용할 닉네임를 입력하세요"
        android:textSize="18sp"
        app:layout_constraintStart_toStartOf="@+id/textView16"
        app:layout_constraintTop_toBottomOf="@+id/textView16" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="76dp"
        android:layout_height="35dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:text="아이디"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView6" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="100dp"
        android:layout_height="35dp"
        android:layout_marginTop="8dp"
        android:text="비밀번호"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="@+id/signup_userId"
        app:layout_constraintTop_toBottomOf="@+id/signup_userId" />

    <TextView
        android:id="@+id/textView11"
        android:layout_width="150dp"
        android:layout_height="35dp"
        android:layout_marginTop="6dp"
        android:text="비밀번호 확인"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="@+id/signup_password"
        app:layout_constraintTop_toBottomOf="@+id/signup_password" />

    <TextView
        android:id="@+id/textView12"
        android:layout_width="100dp"
        android:layout_height="35dp"
        android:layout_marginTop="8dp"
        android:text="이메일"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="@+id/signup_password_ch"
        app:layout_constraintTop_toBottomOf="@+id/signup_password_ch" />

    <TextView
        android:id="@+id/textView15"
        android:layout_width="170dp"
        android:layout_height="35dp"
        android:layout_marginTop="8dp"
        android:text="이메일 인증번호"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="@+id/signup_email"
        app:layout_constraintTop_toBottomOf="@+id/signup_email" />

    <TextView
        android:id="@+id/textView16"
        android:layout_width="170dp"
        android:layout_height="35dp"
        android:layout_marginTop="8dp"
        android:text="닉네임"
        android:textSize="24sp"
        app:layout_constraintStart_toStartOf="@+id/signup_email_ch"
        app:layout_constraintTop_toBottomOf="@+id/signup_email_ch" />

    <Button
        android:id="@+id/signup_plusbutton"
        android:layout_width="335dp"
        android:layout_height="47dp"
        android:layout_marginBottom="40dp"
        android:text="가 입 하 기"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/signup_password"
        app:layout_constraintHorizontal_bias="0.628"
        app:layout_constraintStart_toStartOf="@+id/signup_password" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="회 원 가 입"
        android:textSize="32sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="76dp"
        android:layout_height="49dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/signup" />

    <TextView
        android:id="@+id/signup_server_response"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text=""
        app:layout_constraintBottom_toTopOf="@+id/signup_userId"
        app:layout_constraintEnd_toEndOf="@+id/textView6"
        app:layout_constraintStart_toEndOf="@+id/textView2" />

    <ProgressBar
        android:id="@+id/singup_progressBar"
        android:layout_width="382dp"
        android:layout_height="21dp"
        android:visibility="invisible"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:layout_editor_absoluteY="624dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

signup.php / [ubuntu - php - VScode연동해서 사용]

* dbcon.php가 있어야한다.

* db에 insert하는 부분은 확인해서 본인의 db쿼리에 맞게 넣어야합니다.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include ('dbcon.php');
$android = strpos($_SERVER['HTTP_USER_AGENT'], "Android");

if (($_SERVER['REQUEST_METHOD'] == 'POST') || $android) {
    // 안드로이드 코드의 postParameters 변수에 적어준 이름을 가지고 값을 전달 받습니다.

    $userId = $_POST['sendId']; //아이디
    $userPassword = $_POST['sendPassword']; // 비밀번호
    $userPassword_ch = $_POST['sendPassword_ch']; //비밀번호 재 확인
    $userEmail = $_POST['sendEmail']; // 이메일 받기
    $userEmail_ch = $_POST['sendEmail_ch']; // 이메일 인증번호 확인하기
    $userNickname = $_POST['sendNickname']; // 닉네임 받기

    // 아이디와 비밀번호의 길이를 확인하고, 비밀번호와 비밀번호 확인이 일치하는지 확인합니다.
    if (empty($userId)) {
        $errMSG = "아이디를 확인하세요!";
    } else if (strlen($userId) > 20 || strlen($userId) < 4) {
        $errMSG = "아이디는 4자 이상 20자 이하여야 합니다.";
    } else if (empty($userPassword)) {
        $errMSG = "비밀번호를 확인하세요!";
    } else if (strlen($userPassword) > 16 || strlen($userPassword) < 8) {
        $errMSG = "비밀번호는 8자 이상 16자 이하여야 합니다.";
    } else if (!preg_match('/^(?=.*\d)(?=.*[a-zA-Z])[0-9a-zA-Z]{8,16}$/', $userPassword)) {
        $errMSG = "비밀번호는 숫자와 문자를 모두 포함하여야 합니다.";
    } else if ($userPassword !== $userPassword_ch) {
        $errMSG = "비밀번호와 비밀번호 확인이 일치하지 않습니다.";
    } else if (empty($userEmail)) {
        $errMSG = "이메일을 입력하세요.";
    } else if (!filter_var($userEmail, FILTER_VALIDATE_EMAIL)) {
        $errMSG = "유효한 이메일 주소를 입력하세요.";
    } else if (empty($userNickname)) {
        $errMSG = "닉네임을 입력하세요";
    }
    if (!isset($errMSG)) {
        try {
            // SQL문을 실행하여 데이터를 MySQL 서버의 userinfo 테이블에 저장합니다.
            $stmt = $con->prepare('INSERT INTO userinfo (userId, userPassword, userEmail,userNickname)
                    VALUES(:userId, :userPassword, :userEmail, :userNickname)');

            $stmt->bindParam(':userId', $userId);
            $stmt->bindParam(':userPassword', $userPassword);
            $stmt->bindParam(':userEmail', $userEmail);
            $stmt->bindParam(':userNickname', $userNickname);

            if ($stmt->execute()) {
                $successMSG = "새로운 사용자를 추가했습니다.";
            } else {
                $errMSG = "사용자 추가 에러";
            }
        } catch (PDOException $e) {
            die("Database error: " . $e->getMessage());
        }
    }
}
if (isset($errMSG))
    echo $errMSG;
if (isset($successMSG))
    echo $successMSG;
?>

 

dbcon.php

* 변수 = '  '; <-을 항상 양 옆에 붙여야합니다.

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

$host = '접속할IP 입력';
$username = 'MySQL 계정 아이디';
$password = 'MySQL 계정 패스워드';  
$dbname = 'DATABASE 이름'


$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

try {
    $con = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
} catch (PDOException $e) {
    die("Failed to connect to the database: " . $e->getMessage());
}


$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    function undo_magic_quotes_gpc(&$array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                undo_magic_quotes_gpc($value);
            } else {
                $value = stripslashes($value);
            }
        }
    }

    undo_magic_quotes_gpc($_POST);
    undo_magic_quotes_gpc($_GET);
    undo_magic_quotes_gpc($_COOKIE);
}

header('Content-Type: text/html; charset=utf-8');
#session_start();
?>

 

1. 안드로이드 스튜디오에 Signup.java / b_signup.xml 을 만든다

2. vscode(우분투연동) dbcon.php / signup.php 을 만든다.

3. Signup.java 코드에 자신이 입력할 아이피 주소를 확인 후 작성

4. dbcon.php 코드에 db에 접속할 아이피, mysql 아이디,패스워드

    데이터베이스 이름을 작성한다

5. signup.php에 insert(데이터베이스에 데이터 넣는 쿼리문) 은

    자신이 만든 db형식대로 확인하여 작성한다. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

task.execute("http://" + IP_ADDRESS + "/insert.php", sendId, sendPassword, sendEmail, sendNickname, sendPassword_ch, sendEmail_ch);

 * task execute를 사용해서 AsysncTask를 실행하면서 매개변수를 넣어 줍니다
 * 첫번째 [0번 인덱스] 는 아이피주소 두번째 [1번 인덱스] 는 아이디, 2번 인덱스는 패스워드,

     3번 인덱스는 이메일 을 매개변수를 넣습니다.
 * 비동기 AsysncTask 의 실행 패턴은
 * 실행(execute) -> 백그라운드 작업(doinBackground) [백그라운드 스레드에서 비동기 작업 시작]
 *  -> 진행상황 업데이트(onProgressUpdate) 백그라운드 스레드 진행상황 메인 스레드 전달

     -> 비동기 실행 완료 후 처리(onPostExecute) 메인스레드에 완료상태 전달

 

 

* InputStream 두 가지의 특징이 있습니다

InputStream inputStream = httpURLConnection.getInputStream();


 *  1. 입력받은 데이터는 int형으로 저장되며 이는 10진수의 UTF-16 값으로 저장이 됩니다
 *  2. 1byte로만 읽습니다
 *  이러한 문제로 해결하기 위해 확장된 것이 InputStreamReader 입니다.

InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");


 *  1. InputStream을 문자단위 (character) 데이터로 변환 하는 역할을 합니다.
 *  2. byte -> character 단위로 데이터를 처리 할 수 있도로 변환.
 *  3. char 배열로 데이터를 받을 수 있습니다.

BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

* String 객체와 String 객체를 더하는 행위는 메모리 할당과 메모리 해제를 발생시켜 더하는 연산이 많아지면 성능적으로 좋지 않게됩니다
* StringBuilder 는 문자열을 더 할때 새로운 객체를 만들어서 하는 것이 아닌 기존의 데이터에서 더하는 방식을 사용하기 때문에 속도도 빠르며 상대적으로
* 부하가 적습니다. 긴 문자열을 더하는 상황이 발생 할 경우 StringBuilder,Buffer 을 사용하면 좋다