本文整理匯總了Java中android.os.PowerManager.reboot方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerManager.reboot方法的具體用法?Java PowerManager.reboot怎麽用?Java PowerManager.reboot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.PowerManager
的用法示例。
在下文中一共展示了PowerManager.reboot方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rebootRecovery
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* Reboots the device into the recovery.<br /><br />
*
* This method first tries using the {@link PowerManager}, if that fails it fallbacks on using the reboot command from toolbox.<br /><br />
*
* Note that using the {@link PowerManager} requires your app to optain the 'REBOOT' permission. If you don't want this, just parse NULL as {@link Context}
* and the method will use the fallback. This however is more likely to fail, as many toolbox versions does not support the reboot command.
* And since only the kernel can write to the CBC, we need a native caller to invoke this. So there is no fallback for missing toolbox support when it comes
* to rebooting into the recovery.
*
* @param context
* A {@link Context} or NULL to skip using the {@link PowerManager}
*/
public Boolean rebootRecovery(Context context) {
if (context != null) {
try {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
pm.reboot(null);
/*
* This will never be reached if the reboot is successful
*/
return false;
} catch (Throwable e) {}
}
Result result = mShell.execute("toolbox reboot recovery");
return result != null && result.wasSuccessful();
}
示例2: reboot
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* 重啟
* <p>需係統權限 {@code <android:sharedUserId="android.uid.system"/>}</p>
*
* @param reason 傳遞給內核來請求特殊的引導模式,如"recovery"
*/
public static void reboot(final String reason) {
PowerManager mPowerManager = (PowerManager) Utils.getApp().getSystemService(Context.POWER_SERVICE);
try {
mPowerManager.reboot(reason);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: reboot
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* 重啟
* <p>需係統權限 {@code <android:sharedUserId="android.uid.system"/>}</p>
*
* @param reason 傳遞給內核來請求特殊的引導模式,如"recovery"
*/
public static void reboot(String reason) {
PowerManager mPowerManager = (PowerManager) Utils.getContext().getSystemService(Context.POWER_SERVICE);
try {
mPowerManager.reboot(reason);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: doReboot
import android.os.PowerManager; //導入方法依賴的package包/類
private static void doReboot(Context context, int mode) {
final PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (mode == 0) {
pm.reboot(null);
} else if (mode == 1) {
Utils.performSoftReboot();
} else if (mode == 2) {
replaceRecoveryMessage();
pm.reboot("recovery");
} else if (mode == 3) {
pm.reboot("bootloader");
}
}
示例5: reboot
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* 重啟
* <p>需係統權限 {@code <android:sharedUserId="android.uid.system"/>}</p>
*
* @param reason 傳遞給內核來請求特殊的引導模式,如"recovery"
*/
public static void reboot(String reason) {
PowerManager mPowerManager = (PowerManager) Utils.getContext().getSystemService(Context.POWER_SERVICE);
try {
mPowerManager.reboot(reason);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: reboot
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* 重啟
* <p>需係統權限 {@code <android:sharedUserId="android.uid.system"/>}</p>
*
* @param reason 傳遞給內核來請求特殊的引導模式,如"recovery"
*/
public static void reboot(final String reason) {
PowerManager mPowerManager = (PowerManager) Utils.getContext().getSystemService(Context.POWER_SERVICE);
try {
mPowerManager.reboot(reason);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: reboot
import android.os.PowerManager; //導入方法依賴的package包/類
public static void reboot(Context context){
Log.w(TAG,"reboot");
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
pm.reboot(null);
}