am developing a timetable application that requires to make sound at times set by the user.i need an idea on how to make the application run at the backqround that is been able to access the phone time even when it has been exited.Just like normal alarm in phone.please your responds is highly needed.

Dani AI

Generated

— the key constraint is the MIDlet lifecycle that mentioned: a paused MIDlet does not keep running. That rules out trying to have your code stay alive after the user exits. However, MIDP includes a standard mechanism to wake a suite at a scheduled time: the PushRegistry alarm support (MIDP 2.0). Use it to register an absolute alarm time when the user sets an alarm; the device will launch your MIDlet at that time so it can play the sound.

Practical workflow:

  • Persist the user alarms (RecordStore) when set.
  • Register an alarm with PushRegistry for the chosen absolute timestamp.
  • When the MIDlet is started by the system at the alarm time, read the saved alarm data and play the tone via MMAPI (Manager.createPlayer(...), player.start()) or a simple tone API.
  • Re-register alarms after installs/updates or when the phone reboots if the device does not persist them.

Important cautions: PushRegistry behavior is device-dependent. Some handsets limit how many alarms a suite may register, require signing or user permission, or clear registrations on reboot. Emulators often do not faithfully simulate alarms, so always test on target devices. If PushRegistry is not available or too unreliable on your target phones, the practical alternatives are using platform-native alarm APIs (build a native app), or a server/SMS push to trigger the MIDlet. For the MIDP 2.0 spec see the JSR 118 reference: MIDP 2.0 (JSR 118).

Recommended Answers

All 2 Replies

Schedule the process using Windows Task Scheduler i.e. if you are on Windows platform or the GNome Task Scheduler for Ubuntu.

Schedule the process using Windows Task Scheduler i.e. if you are on Windows platform or the GNome Task Scheduler for Ubuntu.

Please make sure that you read question properly this is JME not standard Java application.

as to answer your question, no you can't do it due to midlet life cycle. When midlet on background it means that is paused and not running. Time scheduler is one of stupid tasks teachers like to give students, that only works if application running.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.