现在的位置: 首页 > 综合 > 正文

android实现静默安装demo

2017年11月18日 ⁄ 综合 ⁄ 共 591字 ⁄ 字号 评论关闭

1、需要RootTools.jar

2、执行脚本

public class InstallerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    }
    
    public void click(View view){
    EditText et = (EditText) findViewById(R.id.editText1);
    String path = et.getText().toString().trim();
    try {
RootTools.sendShell("/system/bin/pm install -r "+path, 30000);
} catch (Exception e) {
e.printStackTrace();
}
    }
}

抱歉!评论已关闭.