- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
您好,我想在手机未被触摸时设置闹钟。如果近2分钟没有触摸屏幕,就会发出警报声。我怎样才能做到这一点?有谁能够帮我?提前致谢。
最佳答案
传递 AlarmService通过下面的代码。这会发现您的设备闲置了多长时间。
idle.java
Handler hl_timeout = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try{
hl_timeout.postDelayed(DoOnTimeOut, 15000);
}catch(Exception e)
{
e.printStackTrace();
}
}
// Toast
Thread DoOnTimeOut = new Thread() {
public void run() {
try{
Toast.makeText(getApplicationContext(), "System is idle", Toast.LENGTH_LONG).show();
}catch(Exception e)
{
e.printStackTrace();
}
}
};
@Override
public void onUserInteraction()
{
super.onUserInteraction();
//Remove any previous callback
try{
hl_timeout.removeCallbacks(DoOnTimeOut);
hl_timeout.postDelayed(DoOnTimeOut, 15000);
}catch(Exception e)
{
e.printStackTrace();
}
}
希望对你有帮助。
关于java - 使用android手机闲置时如何设置闹钟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8985013/
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 6年前关闭。 Improve this
我的 symfony 应用程序 (3.4.8) 似乎忽略了任何延长 session 的尝试。解决此问题的最佳行动方案是什么?文档非常模糊。 应用程序/配置/security.yml security:
如何在Rails应用程序中设置如果任何用户闲置30分钟或特定时间段,则应自动注销该用户。 任何人都可以提出任何解决方案。我正在使用dev进行身份验证。任何帮助表示赞赏。 最佳答案 您应该使用 Time
我发现 Azure 容器实例 (ACI) 非常令人困惑。在 Azure 容器应用中,如果没有请求,服务将缩减至零并停止计费。然而ACI也有这样的功能吗? 例如,如果我部署一个每月调用一次的容器,并且每
我发现 Azure 容器实例 (ACI) 非常令人困惑。在 Azure 容器应用中,如果没有请求,服务将缩减至零并停止计费。然而ACI也有这样的功能吗? 例如,如果我部署一个每月调用一次的容器,并且每
有谁知道我如何编写一个 Javacript 函数,如果浏览器的 Javascript 引擎空闲了一定时间,该函数返回 true ? 我很乐意使用 mootools/jQuery 等,如果更容易的话,我
下面的方法会在 15 分钟后注销用户。但问题是,即使用户处于事件状态,也会将其注销。 我正在寻找解决方案,当用户在整整 15 分钟内不事件时,该方法将把他注销,而不是该方法不会运行。 public v
我需要我的应用程序在设备闲置一定时间后重新打开。换句话说,我的应用程序不会进入休眠模式并进入黑屏,而是会重新打开(假设它在后台运行)。将其视为“空闲屏幕”应用。 这在理论上相当简单,但我什至不知道它是
我正在制作一个需要监视 Gmail 帐户是否有新邮件的程序,为了尽快收到它们,我正在使用 JavaMail 的闲置功能。这是我用来调用 folder.idle() 的线程中的代码片段: //Run m
我的应用程序通过推送通知执行静默后台获取。一切正常,当用户在过去 60 分钟内打开应用程序或在 60 分钟内发送推送通知时,从我们的服务器发送的推送通知会按预期触发静默后台提取 - 即使设备已锁定。
在我的 raspberry pi(raspbian 运行)上,我想在空闲系统 5 分钟后(没有鼠标或键盘操作)将当前桌面切换到桌面 n#0,通过 wmctrl -s 0 和 xprintidle 用于
在 iOS 应用程序中,您可以设置 application.idleTimerDisabled = YES 以防止手机自动锁定。 我需要在移动版 Safari 中为像 Doodle Jump 这样的游
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我一直在 AWS Lambda 中修改 nodejs 代码,由一些 API 网关端点调用。我注意到在没有任何 API 网关调用的情况下经过一定时间后,下一个 API 网关请求将超时。我将收到标准的 L
我是一名优秀的程序员,十分优秀!