android實現靜默安裝demo

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();
}
}
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *