Code example for PowerManager

Methods: goToSleep

0
                    (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
         
        cm.setMobileDataEnabled(false);
 
        PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
        pm.goToSleep( SystemClock.uptimeMillis() );
    } 
 
    /** 
     * Does n't need to do anything wrt Device-Resume., This activity's onResume() is called soon after 
     * the Device-Resume happens by POWER-key press., 
     * So, if the Airplane Mode was earlier enabled by us, lets disable it and bring back the state to 
     * the Device's original state. 
     */ 
    private void restoreOriginalState() { 
        Log.d(TAG, "restoreOriginalState() : " + SystemClock.elapsedRealtime());
 
        // Enable keypad , Disable airplane-mode as we are entering RESUME state 
        setKeypadEnabled(true); 
        setAirplaneModeEnabled(false); 
        ConnectivityManager cm =