I would like to have a silent update in my app without any user interaction. But I always get the error code 139. The hardware is rooted! Can anyone help?
Here is the code:
public class UpdateAPK extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.updateapk);
if (isRooted() == true) {
Toast.makeText(UpdateAPK.this, "Hardware is rooted", Toast.LENGTH_LONG).show();
try {
Process install = Runtime.getRuntime().exec(new String[] {"su", "-c", "pm install -r /mnt/sdcard/app.apk"});
install.waitFor();
if (install.exitValue() == 0) {
// Success :)
Toast.makeText(UpdateAPK.this, "Success!", Toast.LENGTH_LONG).show();
} else {
// Fail
Toast.makeText(UpdateAPK.this, "Failure. Exit code: " + String.valueOf(install.exitValue()), Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
System.out.println(e.toString());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
//Do soemthing else
}
}
Thank you!