//本来准备通过查找城市id后再通过id查找天气信息免去建立数据库的麻烦,但是api不稳定,只能通过建立id数据库来对应查找了
super.onCreate(savedInstanceState);String str = "http://toy.weather.com.cn/SearchBox/searchBox?"+ "callback=jsonp1342857491709&_=1342857620727&language=zh&keyword=guilin";try {URL url = new URL(str);HttpURLConnection cn = (HttpURLConnection) url.openConnection();cn.setConnectTimeout(5 * 1000);cn.setRequestMethod("GET");System.out.println("stream=======" + cn.getInputStream());InputStreamReader in = new InputStreamReader(cn.getInputStream());System.out.println("in======" + in);BufferedReader bu = new BufferedReader(in);String line = bu.readLine().toString();System.out.println("ling=====" + line);} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (ProtocolException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}


更多相关文章

  1. Android数据库SQLite使用详解一 : SQLiteOpenHelper详解
  2. android sqlite数据库封装 实现crud
  3. 在 Android 应用中使用数据库
  4. Android Sqlite数据库跨版本升级 保存之前数据
  5. Android中SQLite数据库介绍
  6. 【android】listview动态更新(与数据库之间的交道)
  7. Android系统源码数据库(mmssms.db)(转)

随机推荐

  1. 精通Android3笔记--第十一章
  2. Android(安卓)网络显示图片 通过代理访问
  3. Mac系统Android(安卓)M源码编译并导入And
  4. Android Intent 总结
  5. 状态栏去掉机主图标
  6. Flutter Android(安卓)打包发布
  7. android post 乱码问题
  8. 【handler】Android定时每十分钟执行一次
  9. android 中对apache httpclient及httpurl
  10. Android清理设备内存具体完整演示样例(一