Ejemplo n.º 1
0
 /**
  * 获取可升级应用
  *
  * @param install已安装应用
  * @return
  */
 public List<ApplicationBean> getNativeUpdateAppsList(List<ApplicationBean> install) {
   List<ApplicationBean> tempList = new ArrayList<ApplicationBean>();
   try {
     String josnString = mNetUtil.connect(con.getApplicationContext(), install);
     JSONObject json = new JSONObject(josnString);
     if (!json.has("appList")) {
       return null;
     }
     JSONArray arr = json.getJSONArray("appList");
     if (null == arr || arr.length() < 1) {
       return null;
     }
     JSONObject updObj;
     ApplicationBean tempApp;
     for (int i = 0; i < arr.length(); i++) {
       tempApp = new ApplicationBean();
       updObj = arr.getJSONObject(i);
       if (updObj.has("id")) {
         tempApp.setId(updObj.getInt("id"));
       }
       tempApp.setPkgName(updObj.getString("packageName"));
       tempApp.setAppName(updObj.getString("appName"));
       tempApp.setVersion(updObj.getString("versionCode"));
       tempApp.setTypeName(updObj.getString("typeName"));
       tempApp.setUrl(RequestParam.SERVICE_IMAGE_URL + updObj.getString("url"));
       tempApp.setIconUrl(RequestParam.SERVICE_IMAGE_URL + updObj.getString("icon"));
       tempList.add(tempApp);
     }
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
   return tempList;
 }