當前位置: 首頁>>代碼示例>>Java>>正文


Java PowerManager.reboot方法代碼示例

本文整理匯總了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();
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:32,代碼來源:Device.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:DeviceUtils.java

示例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();
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:15,代碼來源:DeviceUtils.java

示例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");
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:14,代碼來源:ModPowerMenu.java

示例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();
    }
}
 
開發者ID:tututututututu,項目名稱:BaseCore,代碼行數:15,代碼來源:DeviceUtils.java

示例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();
    }
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:15,代碼來源:DeviceUtils.java

示例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);
}
 
開發者ID:0xbb,項目名稱:Totmann-Android,代碼行數:7,代碼來源:AlarmReceiver.java


注:本文中的android.os.PowerManager.reboot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。