From 346b23660be6d50e94380c47e6e9f9bf1b7cdf92 Mon Sep 17 00:00:00 2001 From: ChenchenJT <37769368+ChenchenJT@users.noreply.github.com> Date: Thu, 24 May 2018 23:03:01 +0800 Subject: [PATCH 1/8] Create user_information.json --- user_information.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 user_information.json diff --git a/user_information.json b/user_information.json new file mode 100644 index 000000000..1c4360d68 --- /dev/null +++ b/user_information.json @@ -0,0 +1,6 @@ +[{ + "id": "764774222", + "name": "陈嘉涛", + "sex": "男", + "area": "广东惠州" +}] From 475562160f90515c43a8d247d3688792a2712f64 Mon Sep 17 00:00:00 2001 From: ChenchenJT <37769368+ChenchenJT@users.noreply.github.com> Date: Thu, 24 May 2018 23:03:23 +0800 Subject: [PATCH 2/8] Delete user_information.json --- user_information.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 user_information.json diff --git a/user_information.json b/user_information.json deleted file mode 100644 index 1c4360d68..000000000 --- a/user_information.json +++ /dev/null @@ -1,6 +0,0 @@ -[{ - "id": "764774222", - "name": "陈嘉涛", - "sex": "男", - "area": "广东惠州" -}] From 520ede22c5c4a71ffe15c27d84bf76972888a255 Mon Sep 17 00:00:00 2001 From: ChenchenJT <37769368+ChenchenJT@users.noreply.github.com> Date: Thu, 24 May 2018 23:03:51 +0800 Subject: [PATCH 3/8] Create user_information.json --- soft1614080902335/user_information.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 soft1614080902335/user_information.json diff --git a/soft1614080902335/user_information.json b/soft1614080902335/user_information.json new file mode 100644 index 000000000..1c4360d68 --- /dev/null +++ b/soft1614080902335/user_information.json @@ -0,0 +1,6 @@ +[{ + "id": "764774222", + "name": "陈嘉涛", + "sex": "男", + "area": "广东惠州" +}] From 0002f924695045bd356297d02727523cac96f679 Mon Sep 17 00:00:00 2001 From: ChenchenJT <37769368+ChenchenJT@users.noreply.github.com> Date: Fri, 25 May 2018 00:46:28 +0800 Subject: [PATCH 4/8] Update user_information.json --- soft1614080902335/user_information.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soft1614080902335/user_information.json b/soft1614080902335/user_information.json index 1c4360d68..fe6c641d6 100644 --- a/soft1614080902335/user_information.json +++ b/soft1614080902335/user_information.json @@ -1,6 +1,6 @@ -[{ +{ "id": "764774222", "name": "陈嘉涛", "sex": "男", "area": "广东惠州" -}] +} From fb9e21e8ab5d87857a372bc0163b854e595cddff Mon Sep 17 00:00:00 2001 From: ChenchenJT <37769368+ChenchenJT@users.noreply.github.com> Date: Fri, 25 May 2018 00:58:25 +0800 Subject: [PATCH 5/8] Update user_information.json --- soft1614080902335/user_information.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/soft1614080902335/user_information.json b/soft1614080902335/user_information.json index fe6c641d6..6d7d02f3d 100644 --- a/soft1614080902335/user_information.json +++ b/soft1614080902335/user_information.json @@ -1,6 +1 @@ -{ - "id": "764774222", - "name": "陈嘉涛", - "sex": "男", - "area": "广东惠州" -} +{"id": "764774222","name": "陈嘉涛","sex": "男","area": "广东惠州"} From ffaa360d9f78b1eab1a740df4a06913b46a3b66c Mon Sep 17 00:00:00 2001 From: ChenchenJT <764774222@qq.com> Date: Fri, 25 May 2018 11:03:07 +0800 Subject: [PATCH 6/8] #6 #994 QQ the 6th lab --- .../Soft1614080902335Activity6.java | 97 +++++++++++ .../manifests/AndroidManifest.xml | 16 +- soft1614080902335/report6.md | 0 .../layout/activity_soft1614080902335_qq6.xml | 157 ++++++++++++++++++ ...\345\205\255\346\210\252\345\233\2761.png" | Bin 0 -> 49673 bytes ...\345\205\255\346\210\252\345\233\2762.png" | Bin 0 -> 23068 bytes 6 files changed, 265 insertions(+), 5 deletions(-) create mode 100644 soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity6.java create mode 100644 soft1614080902335/report6.md create mode 100644 soft1614080902335/res/layout/activity_soft1614080902335_qq6.xml create mode 100644 "soft1614080902335/\345\256\236\351\252\214\345\205\255\346\210\252\345\233\2761.png" create mode 100644 "soft1614080902335/\345\256\236\351\252\214\345\205\255\346\210\252\345\233\2762.png" diff --git a/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity6.java b/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity6.java new file mode 100644 index 000000000..0fd2e3fc1 --- /dev/null +++ b/soft1614080902335/java/androidlabs/hzuapps/edu/soft1614080902335/Soft1614080902335Activity6.java @@ -0,0 +1,97 @@ +package androidlabs.hzuapps.edu.soft1614080902335; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.widget.TextView; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Soft1614080902335Activity6 extends AppCompatActivity { + + String text; + String user_id; + String user_name; + String user_sex; + String user_area; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_soft1614080902335_qq6); + getJson(); + } + + public void getJson() { + new Thread() { + @Override + public void run() { + try { + //你的URL + String url_user = "https://raw.githubusercontent.com/ChenchenJT/android-labs-2018/master/soft1614080902335/user_information.json"; + URL url = new URL(url_user); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setConnectTimeout(5000); + conn.setUseCaches(false); + conn.connect(); + InputStream inputStream = conn.getInputStream(); + InputStreamReader input = new InputStreamReader(inputStream); + BufferedReader buffer = new BufferedReader(input); + if (conn.getResponseCode() == 200) { + String inputLine; + StringBuffer resultData = new StringBuffer(); + while ((inputLine = buffer.readLine()) != null) { + resultData.append(inputLine); + } + + text = resultData.toString();input.close(); + inputStream.close(); + Log.v("Json解析:", text); + backJson(); + } + } catch (Exception e) { + e.printStackTrace(); + } + runOnUiThread(new Runnable() { + @Override + public void run() { + ((TextView) findViewById(R.id.new_id)).setText(user_id); + ((TextView) findViewById(R.id.new_name)).setText(user_name); + ((TextView) findViewById(R.id.new_sex)).setText(user_sex); + ((TextView) findViewById(R.id.new_area)).setText(user_area); + } + }); + } + }.start(); + } + + + public void backJson() { + JSONObject person = null; + try { + person = new JSONObject(JSONTokener(text)); + user_id=person.getString("id"); + user_name=person.getString("name"); + user_sex=person.getString("sex"); + user_area=person.getString("area"); + } catch (JSONException e) { + e.printStackTrace(); + Log.v("错误","Wrong!"); + } + + } + public String JSONTokener(String in) { + // consume an optional byte order mark (BOM) if it exists + if (in != null && in.startsWith("\ufeff")) { + in = in.substring(1); + } + return in; + } +} diff --git a/soft1614080902335/manifests/AndroidManifest.xml b/soft1614080902335/manifests/AndroidManifest.xml index 662642fd6..6ed866e54 100644 --- a/soft1614080902335/manifests/AndroidManifest.xml +++ b/soft1614080902335/manifests/AndroidManifest.xml @@ -9,21 +9,27 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.NoActionBar"> - + - + + + + - - - + + + + + + \ No newline at end of file diff --git a/soft1614080902335/report6.md b/soft1614080902335/report6.md new file mode 100644 index 000000000..e69de29bb diff --git a/soft1614080902335/res/layout/activity_soft1614080902335_qq6.xml b/soft1614080902335/res/layout/activity_soft1614080902335_qq6.xml new file mode 100644 index 000000000..286336050 --- /dev/null +++ b/soft1614080902335/res/layout/activity_soft1614080902335_qq6.xml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +