public boolean isUpdate() {
// 获取当前软件版本
int versionCode = getVersionCode(mContext);
//把version.xml放到网络上,然后获取文件信息
URL url;//定义网络中version.xml的连接
try { //一个测试
url = new URL("http://www.xqzx.org/3g/version2.xml");//创建version.xml的连接地址。
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream inStream = connection.getInputStream();//从输入流获取数据
ParseXmlService service = new ParseXmlService();//将数据通过ParseXmlService这个类解析
mHashMap =service.parseXml(inStream);//得到解析信息
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if(null != mHashMap) {
int serviceCode = Integer.valueOf(mHashMap.get("version"));
//版本判断
if(serviceCode > versionCode) {
return true;
}
}
return false;
}