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?
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.
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);