I am not having more information regarding the sound alert, but while searching on internet I got the code below which is on Sound alert. So, just check whether it is helpful to you or not.
Code:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class soundalert extends MIDlet
implements CommandListener
{
Display dis;
List lstitem;
List choose;
TextBox input;
Ticker ticker = new Ticker("Test GUI Components");
final Alert soundAlert = new Alert("sound Alert");
DateField date = new DateField("Today's date: ", DateField.DATE);
Form form = new Form("Form for Stuff");
Form today = new Form("Today's date");
Gauge gauge = new Gauge("Progress Bar", false, 20, 9);
TextField textfield = new TextField("TextField Label", "abc", 50, 0);
static final Command backCommand = new Command("Back", Command.BACK, 0);
static final Command mainMenuCommand = new Command("Main", Command.SCREEN, 1);
static final Command exitCommand = new Command("Exit", Command.STOP, 2);
String currentMenu;
public soundalert()
{
}
public void startApp() throws MIDletStateChangeException
{
dis = dis.getDisplay(this);
lstitem = new List("Test Components", Choice.IMPLICIT);
lstitem.append("Test TextBox", null);
lstitem.append("Test List", null);
lstitem.append("Test Alert", null);
lstitem.append("Test Date", null);
lstitem.append("Test Form", null);
lstitem.addCommand(exitCommand);
lstitem.setCommandListener(this);
lstitem.setTicker(ticker);
mainMenu();
form.append(gauge);
form.append(textfield);
today.append(date);
}
public void pauseApp()
{
dis = null;
choose = null;
lstitem = null;
ticker = null;
form = null;
today = null;
input = null;
gauge = null;
textfield = null;
}
public void destroyApp(boolean unconditional)
{
notifyDestroyed();
}
void mainMenu()
{
dis.setCurrent(lstitem);
currentMenu = "Main";
}
public void testTextBox()
{
input = new TextBox ("Enter Some Text:", "", 10, TextField.ANY);
input.setTicker(new Ticker( "Testing TextBox"));
input.addCommand(backCommand);
input.setCommandListener(this);
input.setString("");
dis.setCurrent(input);
currentMenu = "input";
}
public void testList()
{
choose = new List("Choose Items", Choice.MULTIPLE);
choose.setTicker(new Ticker("Testing List"));
choose.addCommand(backCommand);
choose.setCommandListener(this);
choose.append("Item 1", null);
choose.append("Item 2", null);
choose.append("Item 3", null);
dis.setCurrent(choose);
currentMenu = "list";
}
public void testAlert()
{
soundAlert.setType(AlertType.ERROR);
soundAlert.setString("** ERROR **");
dis.setCurrent(soundAlert);
}
public void testDate()
{
java.util.Date now = new java.util.Date();
date.setDate(now);
today.addCommand(backCommand);
today.setCommandListener(this);
dis.setCurrent(today);
currentMenu = "date";
}
public void testForm()
{
form.addCommand(backCommand);
form.setCommandListener(this);
dis.setCurrent(form);
currentMenu = "form";
}
public void commandAction(Command c, disable d)
{
String label = c.getLabel();
if (label.equals("Exit"))
{
destroyApp(true);
}
else if (label.equals("Back"))
{
if(currentMenu.equals("list") || currentMenu.equals("input") ||currentMenu.equals("date")|| currentMenu.equals("form"))
{
mainMenu();
}
}
else
{
List down = (List)dis.getCurrent();
switch(down.getSelectedIndex())
{
case 0: testTextBox();
break;
case 1: testList();
break;
case 2: testAlert();
break;
case 3: testDate();
break;
case 4: testForm();
break;
}
}
}
}
Bookmarks