wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes phone listener is not working properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "phone listener is not working properly" Watch "phone listener is not working properly" New topic
Author

phone listener is not working properly

Mutturaj Baradol
Greenhorn

Joined: May 20, 2008
Posts: 7
hi,
In my application i used KeyListener and PhoneListener,
downkey from KeyListener works fine but when i use callConnected or
callDisconnected or callEndedByUser it does not give any response.

below is the code for reference
[code]
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


import net.rim.device.api.system.Application;
import net.rim.device.api.system.KeyListener;
public class NewBuild extends MIDlet implements KeyListener{
MyCanvas canvas;
Display display;
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {


}

protected void pauseApp() {

}

protected void startApp() throws MIDletStateChangeException {
Application.getApplication().addKeyListener(this);
display=Display.getDisplay(this);
this.canvas=new MyCanvas();
display.setCurrent(canvas);
}

public boolean keyChar(char arg0, int arg1, int arg2) {

return false;
}

public boolean keyDown(int arg0, int arg1) {
Alert alert = new Alert("Keycode");
alert.setString ("KeyCode:"+arg0);
Display.getDisplay(this).setCurrent(alert);


return false;
}

public boolean keyRepeat(int arg0, int arg1) {

return false;
}

public boolean keyStatus(int arg0, int arg1) {

return false;
}

public boolean keyUp(int arg0, int arg1) {

return false;
}

}
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import net.rim.blackberry.api.phone.PhoneListener;
import net.rim.device.api.system.*;
public class MyCanvas extends Canvas implements Runnable,CommandListener,KeyListener,PhoneListener
{

NewBuild midlet;
Display display;



protected void paint(Graphics g) {
g.setColor(255,255,255);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0,0,0);
g.drawString("Hello J2me with external RIM API`s" + Application.getApplication().isForeground(), 0, 0, 0);

}
public boolean keyChar(char arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
return false;
}

public boolean keyDown(int arg0, int arg1) {
showAlert("Key listener", "arg0 = " + arg0 + " arg1 = " + arg1);
//handle RED button
if(arg0 == 1179648){
showAlert("Main Midlet","Red Button");
//midlet.exitApp();
return true;
}
// TODO Auto-generated method stub
return false;
}

public boolean keyRepeat(int arg0, int arg1) {
// TODO Auto-generated method stub
return false;
}

public boolean keyStatus(int arg0, int arg1) {
// TODO Auto-generated method stub
return false;
}

public boolean keyUp(int arg0, int arg1) {
// TODO Auto-generated method stub
return false;
}

public void callAdded(int arg0) {
// TODO Auto-generated method stub

}

public void callAnswered(int arg0) {
// TODO Auto-generated method stub

}

public void callConferenceCallEstablished(int arg0) {
// TODO Auto-generated method stub

}

public void callConnected(int arg0) {
showAlert("Call Info","callConnected in RIM ");
// TODO Auto-generated method stub

}

public void callDirectConnectConnected(int arg0) {
// TODO Auto-generated method stub

}

public void callDirectConnectDisconnected(int arg0) {
showAlert("Call Info","callConnectDisconnected");
// TODO Auto-generated method stub

}

public void callDisconnected(int arg0) {
showAlert("Call Info in RIM","callDisConnected in RIM");
// TODO Auto-generated method stub

}

public void callEndedByUser(int arg0) {
showAlert("Call Info in RIM","callEndedByUser in RIM");
// TODO Auto-generated method stub

}

public void callFailed(int arg0, int arg1) {
// TODO Auto-generated method stub

}

public void callHeld(int arg0) {
showAlert("Call Info","callHeld in RIM");
// TODO Auto-generated method stub

}

public void callIncoming(int arg0) {
showAlert("Call Info","callIncoming in RIM");

}

public void callInitiated(int arg0) {
showAlert("Call Info","callInitiated in RIM");
// TODO Auto-generated method stub

}

public void callRemoved(int arg0) {
// TODO Auto-generated method stub

}

public void callResumed(int arg0) {
// TODO Auto-generated method stub

}

public void callWaiting(int arg0) {
showAlert("Call Info","callWaiting");
// TODO Auto-generated method stub

}

public void conferenceCallDisconnected(int arg0) {
// TODO Auto-generated method stub

}

protected void show(Displayable disp){
display.setCurrent(disp);

}
public void showAlert(String title,String msg){

// create Alert object with title
Alert alert = new Alert(title);

// set the message body to the Alert
alert.setString (msg);
alert.setTimeout (Alert.FOREVER);
show(alert);
}
public void run() {
// TODO Auto-generated method stub

}
public void commandAction(Command arg0, Displayable arg1) {
// TODO Auto-generated method stub

}
}
[\code]

thanks
ajj
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

"ajj"

We're not trying to be unfriendly, but you're not complying with one of our most basic rules: Use a Real Name. You've been notified more than once.

Our "sheriffs" may not arrest people, but we do evict those who can't abide by our modest requirements. We're all supposed to be professionals here, so we expect professional behavior.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Originally posted by Tim Holloway:
"ajj"

We're not trying to be unfriendly, but you're not complying with one of our most basic rules: Use a Real Name. You've been notified more than once.

Our "sheriffs" may not arrest people, but we do evict those who can't abide by our modest requirements. We're all supposed to be professionals here, so we expect professional behavior.


Besides, people who use real names get answers faster.
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53


"There are times when the easy things should be quick and easy" [...] "and worry about the theory later" -Fred Hamilton-
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: phone listener is not working properly