2017-09-28 63 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); 
    }