Is there a way in j2me, or at least on nokia phones, to light up the screen after screen saver kicks in? - java-me

I have a midlet which checks some conditions and at some point, when some condition becomes true, I display a pop-up dialog to the user.
If nothing happens for a while, the screen saver kicks in and after that the pop-up is not shown to the user - the screen is simply dark.
Is there way to wake up from the screen saving mode programmatically?
I know I can alert the user by sound and vibration and I do that, but I'd like to be able
to get the screen to react in some way (either to flash the lights, or just turn the light on).
Is there any way to do that?

You can implement showNotify() and hideNotify() from the Canvas class.

Related

LWUIT + Nokia SDK 2.0 Form turning black, when swiped on screen

I'm having a strange problem with the Form of LWUIT. I am making a simple game, which you can control with the touchscreen. I just want to use simple touch events, no swipes. However, when a swipe event happens, the screen turns fully black. After some normal touch events, the picture comes back, but this is really annoying. Which property of the Form do I have to set, that this doesn't happen?
The problem does also occur on the phone itself, not only on the emulator.
Solution:
I had to override the public void pointerDragged(int x, int y) method inside my form (empty body).

blank screen after showing alert in j2me

I have developed a game but this is a serious problem I am facing. I don't have any threads in my code , but whenever I use alert
Display.setCurrent(my_alert)// my_alert has a timeout of 3000ms
then after this alert, a blank white screen appears.When the screen is pressed, then my game canvas reappears. Before setting alert, my game canvas of checkers board is set as the current display. This problems also appears after the automatic keypad lock.
This alert is vital for my game, Kindly suggest a solution.
Issues like that typically indicate missing or incorrect override of GameCanvas method showNotify():
The implementation calls showNotify() immediately prior to this Canvas being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc. The default implementation of this method in class Canvas is empty.
Above method is invoked at return from Alert to prior screen. GameCanvas should somehow trigger repaint of the the screen (eg using repaint or flushGraphics methods), otherwise it will be displayed blank.
The fact that this problems also appears after the automatic keypad lock makes it even more likely that showNotify is not done right in your MIDlet.

how do you control Alert behavior on J2ME phones?

I'm testing my midlet on 2 different Nokia model phones: 7210 Supernova and 6600 Fold.
Both are S40 5th ed SP1, still I get a different behavior with the alerts and I was wondering whether there is a way to fix that.
At various times my MIDlet beeps and puts up a self-dismissing Alert for n seconds (meaning it goes away after n seconds unless the user dismisses it earlier).
If that happens after the phone goes into screen saving mode (darkens), this is what happens:
on the 7210 Supernova, the screen lights up, you see the alert, and if you don't touch it it dismisses itself after n seconds and you can see the background screen - this is the desired behavior.
on the 6600 Fold, you hear the beep, but the screen remains dark. If you now press some button the phone lights up, but only then it displays the alert. The rest is similar. But this is problem because the whole MIDlet is at a stop until the user hits a key.
So I can fix it by not displaying this alert on phones that behave like my 6600, but I still want it on phones that behave like my 7210. Is there a way to check for this
programmatically? what do you check for?

Event called on pressing menu button in nokia touch device

I made a J2ME application(2D game) for nokia touch device like C7, N8 etc.
When I press the menu button while the gameplay is on, I reach the home screen on the device, but in the background, the game music still plays.
Can anyone tell me which event is called on pressing the menu button, and any possible solution to this problem?
Call player.stopPlayer() in hideNotify() method of canvas. Probably gameCanvas of your application.
You can restart the music in showNotify() of your gameCanvas.
Canvas.hideNotify() is called when the midlet goes to background see this article as well

How Can I Make a UIButton With No Animation Effects?

I know the title may be misleading so I'm going to explain what I want to do here.
I have a UIButton, a HUGE UIButton, set right after my application's background image. I configured the button to show this image with a background image I set. When the user taps the button, it gets a huge gray shadow and I really don't want that. So how can I make a button that will maintain it's state no matter what the user tries to do with it? I really don't want it to change at all when the user interacts with it. In fact, I wanted to use an UIImageView instead just to avoid the button animation. Since I couldn't get taps out of the UIImageView, I decided to use a button, but no matter what I touch in IB, the button keeps getting that gray shadow, and I have configured the Selected State and other states to be exactly as my default state.
Figured it out.
glassBackground.adjustsImageWhenHighlighted = NO;
Ideally, I would have loved to do that with IB but I'm happy with this result.

Resources