Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

实验六:Android网络编程 #6

Open
jiaohui opened this issue Feb 13, 2020 · 0 comments
Open

实验六:Android网络编程 #6

jiaohui opened this issue Feb 13, 2020 · 0 comments
Labels
Lab 实验要求

Comments

@jiaohui
Copy link
Collaborator

jiaohui commented Feb 13, 2020

实验目标

  1. 掌握Android网络访问方法;
  2. 理解XML和JSON表示数据的方法。
注意:选择实现的功能,一定要跟你的选题相关!

实验内容(选做一)

  1. 在个人目录中创建一个表示数据的XML或JSON文件;
  2. 数据文件代码提交之后从GitHub获取文件URL;
  3. 在应用中通过网络编程访问GitHub的数据文件;
  4. 在应用中解析并显示文件所包含的数据;
  5. 将应用运行结果截图。
提示:获取GitHub文件URL的方法是,打开文件,再点击Raw按钮。

JSON:https://github.com/hzuapps/android-labs-2020/blob/master/JSON.md
XML:https://github.com/hzuapps/android-labs-2020/blob/master/XML.md

实验内容(选做二)

  1. 从网络下载一个文件(图片、MP3、MP4);
  2. 保存到手机,在应用中使用文件;
  3. 将应用运行结果截图。

实验提示

  1. 可以尝试访问目前已有的一个 JSON 文件:
    https://api.github.com/repos/hzuapps/android-labs-2020/issues

  2. 注意复习和参考前几次实验的步骤与要求:

实验参考

  • 参考代码:下载文件

https://github.com/hzuapps/android-labs-2019/blob/master/examples/java/edu/hzuapps/androidlabs/examples/NetworkActivity.java

https://github.com/hzuapps/android-labs-2019/blob/master/examples/java/edu/hzuapps/androidlabs/examples/NetworkFileDownloader.java

  • 参考代码:解析JSON
String url = "http://my-json-feed";

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
        (Request.Method.GET, url, null, new Response.Listener<JSONObject>() {

    @Override
    public void onResponse(JSONObject response) {
        mTextView.setText("Response: " + response.toString());
    }
}, new Response.ErrorListener() {

    @Override
    public void onErrorResponse(VolleyError error) {
        // TODO: Handle error

    }
});

// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
@jiaohui jiaohui added the Lab 实验要求 label Feb 13, 2020
zengsn added a commit that referenced this issue Nov 23, 2020
Chanlex added a commit to Chanlex/android-labs-2020 that referenced this issue Nov 24, 2020
Playerlhh added a commit to Playerlhh/android-labs-2020 that referenced this issue Nov 24, 2020
Playerlhh added a commit to Playerlhh/android-labs-2020 that referenced this issue Nov 24, 2020
Playerlhh added a commit to Playerlhh/android-labs-2020 that referenced this issue Nov 25, 2020
522090231 added a commit to 522090231/android-labs-2020 that referenced this issue Nov 25, 2020
huangjunxin added a commit to huangjunxin/android-labs-2020 that referenced this issue Nov 25, 2020
zengsn added a commit that referenced this issue Nov 26, 2020
zengsn added a commit that referenced this issue Nov 26, 2020
zengsn added a commit that referenced this issue Nov 26, 2020
zengsn added a commit that referenced this issue Nov 26, 2020
#5 #6 #28 第5、6次实验 含实验报告
zkw55 added a commit to zkw55/android-labs-2020 that referenced this issue Nov 26, 2020
zengsn added a commit that referenced this issue Nov 27, 2020
#6 #143 没有用到网络,完善功能
zengsn added a commit that referenced this issue Nov 27, 2020
zengsn added a commit that referenced this issue Nov 29, 2020
zengsn added a commit that referenced this issue Nov 29, 2020
GBSTS added a commit to GBSTS/android-labs-2020 that referenced this issue Nov 29, 2020
xyl123580 added a commit to xyl123580/android-labs-2020 that referenced this issue Nov 30, 2020
xyl123580 added a commit to xyl123580/android-labs-2020 that referenced this issue Nov 30, 2020
zengsn added a commit that referenced this issue Nov 30, 2020
GBSTS added a commit to GBSTS/android-labs-2020 that referenced this issue Nov 30, 2020
zengsn added a commit that referenced this issue Nov 30, 2020
3ho-y added a commit to 3ho-y/android-labs-2020 that referenced this issue Dec 1, 2020
BBsan13 pushed a commit to BBsan13/android-labs-2020 that referenced this issue Dec 2, 2020
ccc2020916 added a commit to ccc2020916/android-labs-2020 that referenced this issue Dec 2, 2020
15218047860 added a commit to 15218047860/android-labs-2020 that referenced this issue Dec 2, 2020
ccc2020916 added a commit to ccc2020916/android-labs-2020 that referenced this issue Dec 3, 2020
zengsn added a commit that referenced this issue Dec 3, 2020
Chenweikang2 added a commit to Chenweikang2/android-labs-2020 that referenced this issue Jan 13, 2021
zengsn added a commit that referenced this issue Jan 13, 2021
#6 #382 实验六报告+剩余功能实现
zengsn added a commit that referenced this issue Jan 13, 2021
zengsn added a commit that referenced this issue Jan 13, 2021
#6 #61 第六次实验和实验报告
zengsn added a commit that referenced this issue Jan 13, 2021
ValiantRex added a commit to ValiantRex/android-labs-2020 that referenced this issue Jan 13, 2021
Dwweryu added a commit to Dwweryu/android-labs-2020 that referenced this issue Jan 13, 2021
zengsn added a commit that referenced this issue Jan 14, 2021
#6 #7 #66 项目没有用到实验67,另外做了课上的实验
zengsn added a commit that referenced this issue Jan 14, 2021
wicky-yang added a commit to wicky-yang/android-labs-2020 that referenced this issue Jan 14, 2021
Thisko added a commit to Thisko/android-labs-2020 that referenced this issue Jan 14, 2021
hzuapps#6 hzuapps#23 实验6 实验报告 没有用到网络编程,做了例子
Thisko added a commit to Thisko/android-labs-2020 that referenced this issue Jan 14, 2021
Thisko added a commit to Thisko/android-labs-2020 that referenced this issue Jan 14, 2021
yuanxiaoban added a commit to yuanxiaoban/android-labs-2020 that referenced this issue Jan 14, 2021
wzx-tech added a commit to wzx-tech/android-labs-2020 that referenced this issue Jan 15, 2021
Yutao69 pushed a commit to Yutao69/android-labs-2020 that referenced this issue Jan 15, 2021
zcjzzf added a commit to zcjzzf/android-labs-2020 that referenced this issue Jan 15, 2021
JeesionChone added a commit to JeesionChone/android-labs-2020 that referenced this issue Jan 16, 2021
clinying added a commit to clinying/android-labs-2020 that referenced this issue Jan 16, 2021
zengsn added a commit that referenced this issue Jan 17, 2021
#6 #7 #119 实验6、7未用到,做了课上的例子
zengsn added a commit that referenced this issue Jan 17, 2021
#6 #7 #23 实验6、7未用到,做了例子
zengsn added a commit that referenced this issue Jan 17, 2021
#6 #7 #69 实验67未用到,另外做了实验
zengsn added a commit that referenced this issue Jan 17, 2021
#6 #7 #64 未使用网络编程和设备编程,提交实验6、7报告
zengsn added a commit that referenced this issue Jan 17, 2021
#6 #7 #141 实验6、7未用到,做了例子
zengsn added a commit that referenced this issue Jan 17, 2021
zengsn added a commit that referenced this issue Jan 17, 2021
zengsn added a commit that referenced this issue Jan 17, 2021
#6#407 第六、七次实验
zengsn added a commit that referenced this issue Jan 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Lab 实验要求
Projects
None yet
Development

No branches or pull requests

1 participant