2017-09-28 105 views
-5

我正在開發android系統應用程序。直接卸載另一個應用程序,無需用戶交互。 我已經寫的代碼和平,卸載android應用程序無需用戶交互

private void UninsallApp() { 
    Uri packageURI = Uri.parse("package:"+"com.example.shortcutcreation"); 
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); 
    startActivity(uninstallIntent); 
} 

但在此之前卸載應用程序對話框來像 enter image description here

能否請你幫我...

+3

'直接卸載你希望能夠做到這一點未經用戶同意,而無需用戶interaction.'另一個應用程序? – Nikola

+0

是@Nikola,我正在做Android系統管理應用程序。 – Kumar

+0

你知道這個monit的整個觀點是爲了防止你想要完成的活動嗎? –

回答

0

我得到了這個問題的解決方案。 我已經破解了代碼AOSP框架水平(android.content.pm),並作爲ploatform APK ... 最後的應用程序被悄悄卸載簽署...

字符串CMD =「SH /系統/ bin/pm uninstall「+ packageName;

try {Process su = Runtime.getRuntime().exec("su"); 
     DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); 
     outputStream.writeBytes(cmd+"\n"); 
     outputStream.flush(); 
     outputStream.writeBytes("exit\n"); 
     outputStream.flush(); 
     su.waitFor(); 

    } catch (IOException e) { 

     throw new RuntimeException(e); 

    } catch (InterruptedException e) { 

     throw new RuntimeException(e); 
    }