当前位置: 首页>>代码示例>>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;未经允许,请勿转载。