Search code examples
javajava-memidlet

J2ME and mobile phones


can i write a MIDlet that stays "resident" like an agenda, that alarms when a certain event will occur( in other words, the MIDlet API allows the developer write a application that stays running in background)? Within a MIDlet, can i use the vibratory alarm of the cellphone?


Solution

  • There's no clean way to background a J2ME app that works generically across all phones. In most cases phones can only run one app at a time, so even if your app were backgrounded, if another app starts, yours could well get terminated.

    Having said that, you can for some Sony Ericsson and non-old Nokias at least hide you app with something like this in your MIDlet subclass:

    Display.getDisplay( this ).setCurrent( null );
    

    On your other question about vibration alarms: yes, you can use the Display.vibrate() method:

    Display.getDisplay( this ).vibrate( duration );