Android 2.2: Reboot device programmatically

I would like to know if there is a way to reboot the device through code. Ive tried:

Intent i = new Intent(Intent.ACTION_REBOOT); 
i.putExtra("nowait", 1); 
i.putExtra("interval", 1); 
i.putExtra("window", 0); 
sendBroadcast(i);

And added permissions for REBOOT but it still doesnt work.

Thanks


Solution 1:

This seemed to work for me:

try {
        Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
        proc.waitFor();
    } catch (Exception ex) {
        Log.i(TAG, "Could not reboot", ex);
    }