自己做了一個簡單的:
https://github.com/HBU/AndroidTest/tree/master/JsonWeatherInfoSimple
只是從網站讀取JSON數據到本地,沒有解析JSON格式。
涉及到聯網和線程知識點,較為簡單。
從GitHub上找了一個,邊學邊驗證:
https://github.com/leeqibin/JsonWeather21
原有代碼在AndroidManifest.xml配置文件的<application>標簽中插入:
android:usesCleartextTraffic="true"
這是Android P新增的安全要求~
涉及知識點:線程、聯網、JSON、List、SQLite等。
原作者代碼寫的很好,跟着做一遍受益良多。
學習並驗證后的代碼:
https://github.com/HBU/AndroidTest/tree/master/JsonWeatherInfo