本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
示例4: isPowerSaverOn
import android.os.PowerManager; //导入方法依赖的package包/类
static boolean isPowerSaverOn(Context context) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return powerManager.isPowerSaveMode();
}
示例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);
}
示例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();
}