package com.basic.security.utils; public class UpdateApk { public static void getApk() { try { // System1.out.println("UpdateApk.getApk 开始下载"); // String out = new Scanner(new URL(Constants.getApkUrl).openStream(), "UTF-8").useDelimiter("\\A").next(); // Gson gson = new Gson(); // Map map = gson.fromJson(out, Map.class); // if ("true".equals(map.get("hasNewVersion"))) { // String newApkName = (String) map.get("newApkName"); // String newApkSize = (String) map.get("newApkSize"); // String newApkNameUrl = Constants.getApkUrl.substring(0, Constants.getApkUrl.lastIndexOf("/")) + "/" + newApkName; // String dirName = Environment.getExternalStorageDirectory() + "/download/"; // new File(dirName).mkdirs(); // File downloadedFile = new File(dirName, newApkName); // org.apache.commons.io.FileUtils.copyURLToFile(new URL(newApkNameUrl), downloadedFile); // if (Integer.parseInt(newApkSize) == downloadedFile.length()) { // if (Constants.useAlf) { // DeviceControl.startInstallApk( // BaseApplication.getApplication(), // "com.basic.security", // downloadedFile.getAbsolutePath(), // true, // true // ); // } // } // } // // System1.out.println("UpdateApk.getApk 安装完成"); } catch (Exception e) { e.printStackTrace(); } } }