Code:
import java.io.InputStream;
import javax.microedition.media.Player;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.Manager;
import javax.microedition.media.control.VideoControl;
/**
* @author hitesh
*/
public class AirtelMainMidlet extends MIDlet implements CommandListener {
private Display display;
private Form form1;
public Image image;
public List list;
private TextBox TextBox, bTextBox, cTextBox, dTextBox, eTextBox, fTextBox, gTextBox;
// The Commands used in the code.
private Command Next = new Command("Next", Command.OK, 1);
private Command Exit = new Command("Exit", Command.EXIT, 1);
private Command Next1 = new Command("Move on", Command.OK, 1 );
private Command Next2 = new Command("Next", Command.OK, 1 );
private Command Back1 = new Command("Back", Command.BACK ,1);
private Command Demo = new Command("Demo", Command.OK, 1);
private Alert alert;
private Player mPlayer;
private VideoControl mVidc;
private Item mVideoItem;
// Midlet's constuctor
public AirtelMainMidlet()
{
display = Display.getDisplay(this);
form1 = new Form ("Airtel Missed Call Alerts");// setting form 1
form1.addCommand(Next);
form1.addCommand(Exit);
form1.setCommandListener(this);
addData();
// throw new UnsupportedOperationException("Not yet implemented");
}
boolean addData()
{
display = Display.getDisplay(this);
list = new List(" Frequently Asked Questions", List.IMPLICIT);// this is the first line where it shows an error
/*list.append("Question1", null);
list.append("Question2", null);
list.append("Question3", null);*/
list.append("1. Do you have any service to ensure that I don’t miss any important calls?", null);
list.append("2. How do I activate Missed Call Alerts?", null);
list.append("3. Can you activate Missed Call Alerts for me?", null);
list.append("4. What is the monthly rental for Missed Call Alerts?", null);
list.append("5. Will I be able to get missed call alerts for the previous month?", null);
list.append("6. Are Missed Called Alerts free?", null);
list.append("7. Could you please tell me the renewal date for Missed Call Alerts?", null);
list.addCommand(Next2);
list.addCommand(Exit);
list.setCommandListener(this);
return(true);
}
public void playFromResource()
{
try
{
InputStream in = getClass().getResourceAsStream("/Video/Airtel.3gp");
if (in != null)
{
mPlayer = Manager.createPlayer(in, "video/3gpp");
}else
{
alert = new Alert("Alert", "No video", null, null);
display.setCurrent(alert);
return;
}
mPlayer.prefetch();
mPlayer.realize();
if((mVidc = (VideoControl)mPlayer.getControl("VideoControl"))!=null)
{
mVideoItem = (Item)mVidc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
form1.append(mVideoItem);
}
mPlayer.prefetch();
mPlayer.start();
// form1.removeCommand(mPlayCommand);
display.setCurrent(form1);
}
catch (Exception e)
{e.printStackTrace();}
}
public void startApp() {
display.setCurrent(form1);// Calling form1
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == Exit)
{
this.notifyDestroyed(); // Ends the application
}
else if(c == Next) // Clears the contents from the form1 and adds image to it
{
form1.deleteAll();
form1.setTitle("Control Keys");
form1.removeCommand(Next);
form1.removeCommand(Exit);
try{
image = Image.createImage("/Image/Airtel.png");
}catch(Exception e){}
form1.append(image);
form1.addCommand(Exit);
form1.addCommand(Next1);
form1.setCommandListener(this);
}
else if(c == Next1)
{
display = Display.getDisplay(this);
display.setCurrent(list);
}
else if (c == Next2 || c == List.SELECT_COMMAND)
{
int x = list.getSelectedIndex();
/* String selection = list.getString(x);
alert = new Alert("Option Selected", selection, null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.INFO);
display.setCurrent(alert);*/
switch(x) {
case 0:
String string1 = "Explain to the customer that Airtel offers a service called Missed Call Alerts, which helps them to later retrieve their missed call details whenever their phone was switched off or not reachable.";
TextBox aTextBox = new TextBox("", string1, 2048, TextField.UNEDITABLE);
aTextBox.addCommand(Back1);
aTextBox.setCommandListener(this);
display.setCurrent(aTextBox);
break;
case 1:
final String string2 = "Ask the customer to send MCA ACTV to 222 or activate the service from your end if the customer is finding it difficult to do so.Click the Demo button to view the demo.";
bTextBox = new TextBox("", string2, 2048, TextField.UNEDITABLE);
bTextBox.addCommand(Back1);
bTextBox.addCommand(Demo);
bTextBox.setCommandListener(this);
display.setCurrent(bTextBox);
break;
case 2:
final String string3 = "Activate Missed Call Alerts for the customer using the MCA URL.";
cTextBox = new TextBox("", string3, 2048, TextField.UNEDITABLE);
cTextBox.addCommand(Back1);
cTextBox.setCommandListener(this);
display.setCurrent(cTextBox);
break;
case 3:
final String string4 = "Inform the customer that the rental for Missed Call Alerts is Rs 15 per month and this amount will be deducted from their account as soon as the service is activated";
dTextBox = new TextBox("", string4 , 2048, TextField.UNEDITABLE);
dTextBox.addCommand(Back1);
dTextBox.setCommandListener(this);
display.setCurrent(dTextBox);
break;
case 4:
final String string5 = "Tell the customer that they will only get missed call alerts for the last 4 hours and will not be able to get alerts for the previous month.";
eTextBox = new TextBox("", string5, 2048, TextField.UNEDITABLE);
eTextBox.addCommand(Back1);
eTextBox.setCommandListener(this);
display.setCurrent(eTextBox);
break;
case 5:
final String string6= "Explain that Missed Call Alerts is not free and educate the customer about the monthly rental for the service.";
fTextBox = new TextBox("", string6, 2048, TextField.UNEDITABLE);
fTextBox.addCommand(Back1);
fTextBox.setCommandListener(this);
display.setCurrent(fTextBox);
break;
case 6:
final String string7 = "You can find this information under Adjustments in Minsat or OTHR CDR in Pacs. Note down the date and inform the customer.";
gTextBox = new TextBox("", string7, 2048, TextField.UNEDITABLE);
gTextBox.addCommand(Back1);
gTextBox.setCommandListener(this);
display.setCurrent(gTextBox);
break;
}
// throw new UnsupportedOperationException("Not supported yet.");
}
else if (c == Back1)
{
display.setCurrent(list);
}
else if (c == Demo)
{
form1.deleteAll();
form1.setTitle("Demo Video");
form1.removeCommand(Next1);
form1.removeCommand(Exit);
playFromResource();
}
}
}