AI智能
改变未来

android 静默安装apk(区别7.0)

public boolean silentInstall1(){String[] args ={\"pm\", \"install\", \"-i\", \"此处为包名\", \"-r\",UPDATE_APK_PATH};if (Build.VERSION.SDK_INT >= 24){args = new String[]{\"pm\", \"install\", \"-r\", \"-i\", \"此处为包名\", \"--user\",\"0\", UPDATE_APK_PATH};}String result = \"EMPTY\";ProcessBuilder processBuilder = new ProcessBuilder(args);Process process = null;InputStream inIs = null;try{ByteArrayOutputStream baos = new ByteArrayOutputStream();int read = -1;process = processBuilder.start();baos.write(\'/\');inIs = process.getInputStream();while ((read = inIs.read()) != -1){baos.write(read);}byte[] data = baos.toByteArray();result = new String(data, \"utf-8\");Log.d(\"result111\", \"resultString-------->>>\" + result);baos.close();} catch (IOException e){Log.d(\"result1111\", \"静默安装无效!!!\");} finally{try{if (inIs != null){inIs.close();}} catch (IOException e){}if (process != null){process.destroy();}}return result.contains(\"Success\");}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » android 静默安装apk(区别7.0)