- 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();
- }
- }
- }
来源: http://www.phpxs.com/code/1001985/