android系統重啟的方式

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

}
}
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。