1、第一种重启方式
public class RebootActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void click(View view){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_REBOOT);
intent.putExtra("nowait", 1);
intent.putExtra("interval", 1);
intent.putExtra("window", 0);
sendBroadcast(intent);
}
}
在清单文件中加入: android:sharedUserId="android.uid.system"
2、第二种重启方式
public class Reboot2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void click(View view){
while(true){
Toast toast = new Toast(this);
toast.setView(new View(this));
toast.show();
}
}
}