screen

iOS: Can I detect if the device screen is on/off?

感情迁移 提交于 2020-12-30 08:08:01
问题 How can I check if the screen is on or off in iOS? I'd like to know if the screen is currently on, even my app is in the background. I'd like to have an event listener on this. thanks. 回答1: In Swift 3 you can do: override func viewDidLoad() { super.viewDidLoad() // Observer UIApplicationDidBecomeActive,UIApplicationDidEnterBackground NotificationCenter.default.addObserver( self, selector: #selector(MyViewController.applicationDidBecomeActive(notification:)), name: NSNotification.Name

Proximity sensor not working with screen turned off?

妖精的绣舞 提交于 2020-12-06 03:47:40
问题 Hy, I have a problem related to the proximity sensor. When I put the finger on it, I want to turn the screen off and when I take the finger, I want to turn the screen on. I successfully did the turning off part, but when I take the finger off the sensor, it does not seem to execute the onSensorChanged method. Here is the code for it: public void onSensorChanged(SensorEvent event) { float distance = event.values[0]; boolean active = (distance >= 0.0 && distance < PROXIMITY_THRESHOLD &&

How do I edit my code to make the 'next' button lead to a blank page IN THE SAME WINDOW? (not a new window )

不问归期 提交于 2020-08-09 08:19:13
问题 from tkinter import Tk, Canvas, Frame, BOTH from tkinter import * from tkinter import Tk #Welcome screen root = Tk() root.configure(bg = "steel blue") canvas = Canvas(root, bg = "steel blue", highlightthickness = 0) canvas.config(width = 350, height = 250) #canvas.config(width = root.winfo_screenwidth(), height = root.winfo_screenheight() ) canvas.pack() #Making of the round rectangle class Rectangle: def round_rectangle(x1, y1, x2, y2, radius=25, **kwargs): points = [x1+radius, y1, x1+radius

How do I edit my code to make the 'next' button lead to a blank page IN THE SAME WINDOW? (not a new window )

不羁岁月 提交于 2020-08-09 08:18:27
问题 from tkinter import Tk, Canvas, Frame, BOTH from tkinter import * from tkinter import Tk #Welcome screen root = Tk() root.configure(bg = "steel blue") canvas = Canvas(root, bg = "steel blue", highlightthickness = 0) canvas.config(width = 350, height = 250) #canvas.config(width = root.winfo_screenwidth(), height = root.winfo_screenheight() ) canvas.pack() #Making of the round rectangle class Rectangle: def round_rectangle(x1, y1, x2, y2, radius=25, **kwargs): points = [x1+radius, y1, x1+radius

How to find out if mobile has a notch or not

北城余情 提交于 2020-08-05 04:13:09
问题 I need to modify the app's toolbar if the notch is present. Right now that notch hides bit of content in toolbar. if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { setTheme(R.style.AppTheme_NoActionBarHello); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(ContextCompat

How to redirect to another page when user click on json data on screen and pass symbol value to another class

耗尽温柔 提交于 2020-06-13 11:30:04
问题 I am using react native and expo. I have some json data on the screen (similator iOS) such as A Acompany B Bcompany here A is symbol and Acompany is name When user click on it it should redirect to another screen such as (Stock.js) and pass the symbol as well? How can I redirect it to another screen when user click on it and send this data ( symbol )? My code: import React, { useState, useEffect } from "react"; import { StyleSheet, View, TouchableWithoutFeedback, Keyboard, FlatList, TextInput

FLAG_TURN_SCREEN_ON does not always work

不想你离开。 提交于 2020-06-11 17:36:14
问题 i start an activity from a BroadcastReceiver, which is triggered by an alaram (RTC_WAKEUP type). in onCreate of that activity i add these flags getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ); problem is that sometimes (approximately 10% cases) the screen does not turn on. the alarm is correctly triggered (i here the sound