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


Java PowerManager.isPowerSaveMode方法代碼示例

本文整理匯總了Java中android.os.PowerManager.isPowerSaveMode方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerManager.isPowerSaveMode方法的具體用法?Java PowerManager.isPowerSaveMode怎麽用?Java PowerManager.isPowerSaveMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.PowerManager的用法示例。


在下文中一共展示了PowerManager.isPowerSaveMode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BatteryInfoManager

import android.os.PowerManager; //導入方法依賴的package包/類
protected BatteryInfoManager(Context context, XSharedPreferences prefs) {
    mContext = context;
    mBatteryData = new BatteryData();
    mListeners = new ArrayList<BatteryStatusListener>();
    mSounds = new Uri[4];
    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mBatteryData.isPowerSaving = mPowerManager.isPowerSaveMode();

    setSound(BatteryInfoManager.SOUND_CHARGED,
            prefs.getString(GravityBoxSettings.PREF_KEY_BATTERY_CHARGED_SOUND, ""));
    setSound(BatteryInfoManager.SOUND_PLUGGED,
            prefs.getString(GravityBoxSettings.PREF_KEY_CHARGER_PLUGGED_SOUND, ""));
    setSound(BatteryInfoManager.SOUND_UNPLUGGED,
            prefs.getString(GravityBoxSettings.PREF_KEY_CHARGER_UNPLUGGED_SOUND, ""));

    try {
        mLowBatteryWarningPolicy = LowBatteryWarningPolicy.valueOf(prefs.getString(
            GravityBoxSettings.PREF_KEY_LOW_BATTERY_WARNING_POLICY, "DEFAULT"));
    } catch (Throwable t) {
        mLowBatteryWarningPolicy = LowBatteryWarningPolicy.DEFAULT;
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:23,代碼來源:BatteryInfoManager.java

示例2: isPowerSaveModeEnabled

import android.os.PowerManager; //導入方法依賴的package包/類
@TargetApi(21)
public static boolean isPowerSaveModeEnabled(@NonNull PowerManager powerManager) {
  if (Build.VERSION.SDK_INT < 21) return false;

  try {
    return powerManager.isPowerSaveMode();
  } catch (Exception e) {
    return false;
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:Utils.java

示例3: getAnimatorSpeed

import android.os.PowerManager; //導入方法依賴的package包/類
public static float getAnimatorSpeed(Context context) {
    PowerManager powerManager = (PowerManager)
            context.getSystemService(Context.POWER_SERVICE);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && powerManager.isPowerSaveMode()) {
        // Animations are disabled in power save mode, so just show a toast instead.
        return 0.0f;
    }
    return android.provider.Settings.Global.getFloat(context.getContentResolver(),
            android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f);
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:12,代碼來源:Util.java

示例4: isPowerSaverOn

import android.os.PowerManager; //導入方法依賴的package包/類
static boolean isPowerSaverOn(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return powerManager.isPowerSaveMode();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:5,代碼來源:Utilities.java

示例5: onCreate

import android.os.PowerManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this));

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Native init
    jni_init();
    boolean pcap = prefs.getBoolean("pcap", false);
    setPcap(pcap, this);

    prefs.registerOnSharedPreferenceChangeListener(this);

    Util.setTheme(this);
    super.onCreate();

    HandlerThread commandThread = new HandlerThread(getString(R.string.app_name) + " command", Process.THREAD_PRIORITY_FOREGROUND);
    HandlerThread logThread = new HandlerThread(getString(R.string.app_name) + " log", Process.THREAD_PRIORITY_BACKGROUND);
    HandlerThread statsThread = new HandlerThread(getString(R.string.app_name) + " stats", Process.THREAD_PRIORITY_BACKGROUND);
    commandThread.start();
    logThread.start();
    statsThread.start();

    commandLooper = commandThread.getLooper();
    logLooper = logThread.getLooper();
    statsLooper = statsThread.getLooper();

    commandHandler = new CommandHandler(commandLooper);
    logHandler = new LogHandler(logLooper);
    statsHandler = new StatsHandler(statsLooper);

    // Listen for power save mode
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !Util.isPlayStoreInstall(this)) {
        PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
        powersaving = pm.isPowerSaveMode();
        IntentFilter ifPower = new IntentFilter();
        ifPower.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
        registerReceiver(powerSaveReceiver, ifPower);
        registeredPowerSave = true;
    }

    // Listen for user switches
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        IntentFilter ifUser = new IntentFilter();
        ifUser.addAction(Intent.ACTION_USER_BACKGROUND);
        ifUser.addAction(Intent.ACTION_USER_FOREGROUND);
        registerReceiver(userReceiver, ifUser);
        registeredUser = true;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // Listen for idle mode state changes
        IntentFilter ifIdle = new IntentFilter();
        ifIdle.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
        registerReceiver(idleStateReceiver, ifIdle);
        registeredIdleState = true;
    }

    // Listen for connectivity updates
    IntentFilter ifConnectivity = new IntentFilter();
    ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(connectivityChangedReceiver, ifConnectivity);
    registeredConnectivityChanged = true;

    // Listen for added applications
    IntentFilter ifPackage = new IntentFilter();
    ifPackage.addAction(Intent.ACTION_PACKAGE_ADDED);
    ifPackage.addAction(Intent.ACTION_PACKAGE_REMOVED);
    ifPackage.addDataScheme("package");
    registerReceiver(packageChangedReceiver, ifPackage);
    registeredPackageChanged = true;

    // Setup house holding
    Intent alarmIntent = new Intent(this, ServiceSinkhole.class);
    alarmIntent.setAction(ACTION_HOUSE_HOLDING);
    PendingIntent pi = PendingIntent.getService(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    am.setInexactRepeating(AlarmManager.RTC, SystemClock.elapsedRealtime() + 60 * 1000, AlarmManager.INTERVAL_HALF_DAY, pi);
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:81,代碼來源:ServiceSinkhole.java

示例6: isPowerSaverOn

import android.os.PowerManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean isPowerSaverOn(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return ATLEAST_LOLLIPOP && powerManager.isPowerSaveMode();
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:6,代碼來源:Utilities.java


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