本文整理匯總了Java中android.os.PowerManager.isScreenOn方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerManager.isScreenOn方法的具體用法?Java PowerManager.isScreenOn怎麽用?Java PowerManager.isScreenOn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.PowerManager
的用法示例。
在下文中一共展示了PowerManager.isScreenOn方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: wakeScreen
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* Waking up the screen
* * * */
private static void wakeScreen(Context context){
// Waking the screen so the user will see the notification
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH)
isScreenOn = pm.isScreenOn();
else
isScreenOn = pm.isInteractive();
if(!isScreenOn)
{
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
|PowerManager.ON_AFTER_RELEASE
|PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyLock");
wl.acquire(5000);
wl.release();
}
}
示例2: onCreate
import android.os.PowerManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RLog.d(TAG, "BaseCallActivity onCreate");
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
shouldRestoreFloat = true;
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = pm.isScreenOn();
if (!isScreenOn) {
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "bright");
wl.acquire();
wl.release();
}
handler = new Handler();
mHomeKeyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (SYSTEM_DIALOG_REASON_HOME_KEY.equals(reason) && shouldShowFloat) {
finish();
}
}
}
};
try {
registerReceiver(mHomeKeyReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
} catch (Exception e) {
e.printStackTrace();
}
isFinishing = false;
RongCallProxy.getInstance().setCallListener(this);
}
示例3: isIdle
import android.os.PowerManager; //導入方法依賴的package包/類
@SuppressWarnings({"deprecation", "ConstantConditions"})
public static boolean isIdle(Context context) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return powerManager.isDeviceIdleMode() || !powerManager.isInteractive();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
return !powerManager.isInteractive();
} else {
return !powerManager.isScreenOn();
}
}
示例4: queueNextRefresh
import android.os.PowerManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
static void queueNextRefresh(long delay) {
PowerManager powerManager = (PowerManager) mContext
.getSystemService(Context.POWER_SERVICE);
if (powerManager.isScreenOn()) {
Message msg = mHandler.obtainMessage(REFRESH);
mHandler.removeMessages(REFRESH);
mHandler.sendMessageDelayed(msg, delay);
}
}
示例5: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
/** 屏幕是否處於活動狀態 */
public static boolean isScreenOn() {
PowerManager pm = getPowerManager();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
return pm.isInteractive();
} else {
return pm.isScreenOn();
}
}
示例6: isInteractive
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* @return Whether the screen of the device is interactive.
*/
@SuppressWarnings("deprecation")
public static boolean isInteractive(Context context) {
PowerManager manager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
return manager.isInteractive();
} else {
return manager.isScreenOn();
}
}
示例7: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
//noinspection deprecation
return powerManager.isScreenOn();
} else {
return powerManager.isInteractive();
}
}
示例8: isInteractive
import android.os.PowerManager; //導入方法依賴的package包/類
public static boolean isInteractive(Context context) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH)
return (pm != null && pm.isScreenOn());
else
return (pm != null && pm.isInteractive());
}
示例9: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF) {
return true;
}
}
return false;
} else {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return powerManager.isScreenOn();
}
}
示例10: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
private boolean isScreenOn() {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
// API >= 20
return pm.isInteractive();
}
// API <= 19, use deprecated
//noinspection deprecation
return pm.isScreenOn();
}
示例11: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
/**
* 設備屏幕是否是點亮的
* retrue 如果為true,則表示屏幕“亮”了,否則屏幕“暗”了
*/
public static boolean isScreenOn() {
PowerManager pm = (PowerManager) UtilManager.getContext().getSystemService(Context.POWER_SERVICE);
//如果為true,則表示屏幕“亮”了,否則屏幕“暗”了。
return pm.isScreenOn();
}
示例12: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
public static boolean isScreenOn(Context context) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return pm.isScreenOn();
}
示例13: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
public static final boolean isScreenOn(Context context) {
PowerManager powerManager = (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
return powerManager.isScreenOn();
}
示例14: onPause
import android.os.PowerManager; //導入方法依賴的package包/類
@Override
protected void onPause() {
super.onPause();
PowerManager p = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
if(!p.isInteractive()){System.gc();}}else {if(!p.isScreenOn()){System.gc();}}}
示例15: isScreenOn
import android.os.PowerManager; //導入方法依賴的package包/類
public static boolean isScreenOn() {
PowerManager pm = (PowerManager) BaseApplication.context()
.getSystemService(Context.POWER_SERVICE);
return pm.isScreenOn();
}