diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb6828..5d19981 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2ad10af..76f6c4e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,11 @@ + + + { + @Override + protected String doInBackground(String... urls) { + try { + return getHtmlFromHttp(urls[0]); + } catch (IOException e) { + return "Unable to retrieve web page."; + } + } + + @Override + protected void onPostExecute(String result) { + results = result; + + // 지금 result : html + // parsing -> JsonArray + String jsonStr = "hi"; + try { + JSONArray a = new JSONArray(jsonStr); + } catch (JSONException e) { + e.printStackTrace(); + } + + pm_tv.setText("결과값"); + } + } + + private String getHtmlFromHttp(String myUrl) throws IOException { + InputStream is = null; + String str = ""; + + try { + URL url = new URL(myUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setReadTimeout(10000); + conn.setConnectTimeout(10000); + conn.setRequestMethod("GET"); + conn.setDoInput(true); + + conn.connect(); + int resCode = conn.getResponseCode(); + + if (resCode == HttpURLConnection.HTTP_OK) { + StringBuffer sb = new StringBuffer(); + + is = conn.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = br.readLine()) != null) { + sb.append(line); + } + str = sb.toString(); + + + } else { + conn.disconnect(); + } + } finally { + if (is != null) { + is.close(); + } + } + + return str; + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 18bc94c..786f126 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,25 +1,40 @@ - - + - + - + - + - - + + + + + + + + diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 0bff862..31cb713 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -9,17 +9,27 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main" tools:context=".MainActivity"> - + + + + + + + + -