Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实验六:Android网络编程 #6

Open
zengsn opened this issue Mar 24, 2018 · 0 comments
Open

实验六:Android网络编程 #6

zengsn opened this issue Mar 24, 2018 · 0 comments
Labels
Lab 实验要求

Comments

@zengsn
Copy link
Contributor

zengsn commented Mar 24, 2018

实验目标

  1. 掌握Android网络访问方法;
  2. 理解XML和JSON表示数据的方法。

实验内容(选做一)

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

实验内容(选做二)

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

实验提示

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

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

实验参考(待更新)

  • 参考代码:下载文件

https://github.com/hzuapps/android-labs-2017/blob/master/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/examples/NetworkActivity.java

https://github.com/hzuapps/android-labs-2017/blob/master/AndroidLabs/app/src/main/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" /> 
@zengsn zengsn added the Lab 实验要求 label Mar 24, 2018
GeekLee1998 added a commit to GeekLee1998/android-labs-2018 that referenced this issue May 21, 2018
yangyangyang2017 added a commit to yangyangyang2017/android-labs-2018 that referenced this issue May 21, 2018
yangyangyang2017 added a commit to yangyangyang2017/android-labs-2018 that referenced this issue May 21, 2018
lin1472 added a commit to lin1472/android-labs-2018 that referenced this issue May 21, 2018
GeekLee1998 added a commit to GeekLee1998/android-labs-2018 that referenced this issue May 21, 2018
yangyangyang2017 added a commit to yangyangyang2017/android-labs-2018 that referenced this issue May 21, 2018
GeekLee1998 added a commit to GeekLee1998/android-labs-2018 that referenced this issue May 21, 2018
PickForSth added a commit to PickForSth/android-labs-2018 that referenced this issue May 22, 2018
yangyangyang2017 added a commit to yangyangyang2017/android-labs-2018 that referenced this issue May 22, 2018
zengsn added a commit that referenced this issue May 22, 2018
yangyangyang2017 added a commit to yangyangyang2017/android-labs-2018 that referenced this issue May 22, 2018
zengsn added a commit that referenced this issue May 22, 2018
zengsn added a commit that referenced this issue May 23, 2018
erduoLeading added a commit to erduoLeading/android-labs-2018 that referenced this issue May 23, 2018
hzutanziyang added a commit to hzutanziyang/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
wuhengxin added a commit to wuhengxin/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
zglx added a commit to zglx/android-labs-2018 that referenced this issue May 23, 2018
bujingyu added a commit to bujingyu/android-labs-2018 that referenced this issue May 23, 2018
xiaozzcc added a commit to xiaozzcc/android-labs-2018 that referenced this issue May 24, 2018
Mrwuwu12138 added a commit to Mrwuwu12138/android-labs-2018 that referenced this issue May 24, 2018
Mrwuwu12138 added a commit to Mrwuwu12138/android-labs-2018 that referenced this issue May 24, 2018
kebo24 added a commit to kebo24/android-labs-2018 that referenced this issue May 24, 2018
1614080902102 added a commit to 1614080902102/android-labs-2018 that referenced this issue May 24, 2018
1614080902102 added a commit to 1614080902102/android-labs-2018 that referenced this issue May 24, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
#5  第五次实验, #6 第六次实验
zengsn added a commit that referenced this issue Jun 2, 2018
#5 #6 实验5(修改),实验6
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
Susie-Lau added a commit to Susie-Lau/android-labs-2018 that referenced this issue Jun 2, 2018
Susie-Lau added a commit to Susie-Lau/android-labs-2018 that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
#6 #906第六次实验+第4,5次实验报告
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
#5 #6 第五和第六次实验和报告。
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn pushed a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
#6 #931 第六次实验+补交报告二+修改报告三
zengsn added a commit that referenced this issue Jun 2, 2018
#6 #929 第六次实验和实验报告
zengsn added a commit that referenced this issue Jun 2, 2018
#4 #5 #6 #1338 实验四 实验五 实验六
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 2, 2018
zengsn added a commit that referenced this issue Jun 6, 2018
w123rq added a commit to w123rq/android-labs-2018 that referenced this issue Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lab 实验要求
Projects
None yet
Development

No branches or pull requests

1 participant