BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-22-2008, 02:24 AM   #1
ajj_dev@yahoo.com
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 7100
PIN: N/A
Carrier: Sprint
Posts: 31
Default Issue related to phoneListener

Please Login to Remove!

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

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeExcepti on;


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

}
}


thanks
ajj
Offline  
Old 05-22-2008, 03:25 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

slightly off-topic: if you use abstractphonelistener you don't have to implement all the empty methods -> tidy code
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Server Aprons with 5 Pockets - Waiter Waitress Waist Apron (Pack of 2) - Black picture

Server Aprons with 5 Pockets - Waiter Waitress Waist Apron (Pack of 2) - Black

$14.99



Server Book for Waitress Waiter Organizer Wallet with Zipper Pocket Card Holder picture

Server Book for Waitress Waiter Organizer Wallet with Zipper Pocket Card Holder

$13.29



Server Book Organizer Zipper Pocket for Waitress Waiter Bartender Card Holder picture

Server Book Organizer Zipper Pocket for Waitress Waiter Bartender Card Holder

$13.29



Server Book Organizer PU Leather Restaurant Guest Check Presenters Card Holder picture

Server Book Organizer PU Leather Restaurant Guest Check Presenters Card Holder

$13.39



Moxa NPort 5410 4-port RS-232 Serial Device Server  picture

Moxa NPort 5410 4-port RS-232 Serial Device Server

$89.00



Sonic Server 5x9 Double Magnetic Pocket Server Book Organizer Black Taller Size picture

Sonic Server 5x9 Double Magnetic Pocket Server Book Organizer Black Taller Size

$15.99







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.