开发者

program hangs before goToSleep();

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_S开发者_如何学JAVAERVICE);

       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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜