2
我有必須使用時安裝的Android程序,這是一個企業應用程序,我想運行時安裝客戶默默地更新應用無法執行時安裝程序
我有一個方法這可能會運行下午安裝但沒有發生,我不明白爲什麼?有人可以幫助我嗎?
private void installproperlyApp(){
Process process = null;
try{
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
System.out.println("DANS LE INSTALL COMMAND");
os.writeBytes("pm install -r /sdcard/telegestion.apk"+"\n");
os.writeBytes("exit\n");
os.flush();
os.close();
String line ="";
//on récupère l'inputStream sinon on a un deadLock pour le process
BufferedReader inputProcess = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = inputProcess.readLine()) != null) {
System.out.println(line);
}
//on récupère l'errorStream sinon on a un deadLock pour le process
BufferedReader errorProcess = new BufferedReader(new InputStreamReader(process.getErrorStream()));
while ((line = errorProcess.readLine()) != null) {
System.out.println(line);
}
//process.waitFor();
} catch (IOException e) {
System.out.println(e.toString());
} finally {
if (process != null)
process.destroy();
}
}
Bienvenue sur Stack,首次提出的問題,elle est bienposée,bonne continuation! –
你的代碼解決了我的問題。謝謝。 – Aldridge1991