handler.sendEmptyMessageDelayed(1, 1000);屏幕休眠后不运行
发布时间:2018-02-01 来源:查字典编辑
摘要:Handlerhandler=newHandler(){publicvoidhandleMessage(Messagemsg){super....
Handler handler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 1) {
x++;
handler.sendEmptyMessageDelayed(1, 1000);
}
屏幕亮时,x是每秒加一次,屏幕休眠后就不加了,为什么
回复讨论(解决方案)
加了这句,禁用休眠 可以了getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 来个拿分我结贴
拿分的来了,哈哈哈哈