程序在 goToSleep() 之前挂起;
您好,我有这个程序,它使用语音命令来解锁手机。
在此 VoiceRecog 活动中,当我检测到命令错误时,它将调用 goToSleep(1000);这会锁定设备。
但是,该程序将在进入睡眠状态之前挂起。可能是什么问题?我应该在方法中为 int 值添加什么?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if(command ==right)
....
else
pm.goToSleep(10);
}
我尝试过使用
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
devicePolicyManager.lockNow();
,但程序在锁定之前仍然挂起。
Hi i have this program where it uses voice command to unlock the phone.
In this VoiceRecog activity, when i detected command is wrong, it will call goToSleep(1000); which locks the device.
However, the program will hang before it goes to sleep. What could be the problem? What should i put for the int value in the method?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if(command ==right)
....
else
pm.goToSleep(10);
}
I have tried using
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
devicePolicyManager.lockNow();
but the program still hangs before it locks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只有签名为系统应用程序的应用程序才能调用 goToSleep(),而不是您的应用程序。至少现在,我没有看到任何强制设备睡眠的好方法。
Only app signed as system app can call goToSleep(), not yours. And at least now, I don't see any good way to force the device to sleep.