标签:try round feed cte abs class tostring json protect
new AsyncTask<String,Void,String>(){
@Override
protected String doInBackground(String... strings) {
String path=strings[0];
try {
URL url=new URL(path);
HttpURLConnection con= (HttpURLConnection) url.openConnection();
if(code==200){
InputStream is=con.getInputStream();
ByteArrayOutputStream baos=new ByteArrayOutputStream();
byte[] buffer=new byte[1024];
int len=0;
while ((len=is.read(buffer))!=-1){
baos.write(buffer,0,len);
}
//hajjahdjhabs
//juguyg
is.close();
baos.flush();
baos.close();
return baos.toString();
}
;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
Gson gson=new Gson();
TouTiao tt=gson.fromJson(s,TouTiao.class);
list=tt.data.pc_feed_focus;
MyAdapter adapter=new MyAdapter(MainActivity.this,list);
listView.setAdapter(adapter);
}
}.execute("http://www.toutiao.com/api/pc/focus/");
标签:try round feed cte abs class tostring json protect
原文地址:http://www.cnblogs.com/wang-chunqi/p/7602016.html