Disabling Sleep Mode in Blackberry using Code

别说谁变了你拦得住时间么 提交于 2020-01-04 18:01:22

问题


How to prevent the app from going to sleep mode in blackberry using J2ME?

I have seen this suggestion to do a Key Injection also read this docs from Native SDK.

But I am not sure whether the second method works with J2ME.

How can I do this efficently in blackberry with J2ME?


回答1:


I think this may be achieved ... you can send keyBoard event to the device. For more information see this Prevent BlackBerry From Going Into Sleep Mode.




回答2:


About disabling sleep mode, you can read this article.

To solve this problem in blackberry I used code below:

import net.rim.device.api.system.Backlight;
import net.rim.device.api.util.DateTimeUtilities;

int MAX_BACKLIGHT_TIMEOUT_SECS = 255;

....

Backlight.setTimeout(MAX_BACKLIGHT_TIMEOUT_SECS);
Timer timer_ = new Timer();

timer_.scheduleAtFixedRate(new TimerTask() 
{
    public void run() 
    {
        Backlight.enable(true);
    }
}, 
(MAX_BACKLIGHT_TIMEOUT_SECS - 1) * DateTimeUtilities.ONESECOND, 
(MAX_BACKLIGHT_TIMEOUT_SECS - 1) * DateTimeUtilities.ONESECOND);


来源:https://stackoverflow.com/questions/9093706/disabling-sleep-mode-in-blackberry-using-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!