首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android的前后台通讯

2012-12-23 
android的前后台通信前台这个小demo是使用手机登陆和后台的web站点通信手机项目中的: activity_main.xml布

android的前后台通信

前台

这个小demo是使用手机登陆和后台的web站点通信

手机项目中的: activity_main.xml布局xml的配置

 

和后台通信的本质还是通过http协议来发送请求和接受请求的,所以要实现通信的效果,还需要有辅助的类来实现,可以不需要太明白这三个类的具体操作,知道如何使用就可以了

HttpHelper类:

public class WebUtils{    //resonpse返回值    public static void writeJson(HttpServletResponse response,String result)    {    response.setContentType("application/json;charset=utf-8");    PrintWriterout;    try        {            out=response.getWriter();            out.write(result);            out.flush();            out.close();        }        catch (IOException e)        {            e.printStackTrace();        }       }}

因为在项目中也用到了Json所以也需要到上面谈到的几个包


热点排行