07-29-2009 03:51 AM
I am using JDE 4.5, Whaever u told I have done the same thing but still I am not able to detecting my application after pressing the green key..
If I enter a number 9930565658 and presses the green key button, Only entered number is dialing but not detecting my application .
Also in keyDown() method what I have to write inside the switch case KEY_SEND.
Plz check my below code and suggest me.
public class SampleKeypad extends UiApplication { public static String tf="1802107"; public static void main(String[] args) { SampleKeypad theApp = new SampleKeypad(); theApp.enterEventDispatcher(); } public SampleKeypad() { pushScreen(new Express()); } } class Express extends MainScreen implements PhoneListener { public static String str; public static String phno; public static String phNumber; public static AutoTextEditField Num; public static ButtonField dialButton; public static String tf="1802107"; public static String regNum ="911066464646"; public static String pinNum ="8308"; public static String result; public String phone; public static PersistentObject mystoreNum = PersistentStore.getPersistentObject(0xd6dc779737bc
c266L); public Express() { super(); LabelField title = new LabelField("Welcome",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); setTitle(title); PhoneArguments call = new PhoneArguments(PhoneArguments.ARG_CALL, tf); Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call); } public void callConnected(int callId) { System.out.println("Inside Call Connected..."); try { PhoneCall pcall=Phone.getCall(callId); if(pcall.isOutgoing()) { this.callAnswered(callId); } } catch(Exception e) { System.out.println("Exception inside Call Connected try block...:"); } } public void callAdded(int callId) { // TODO Auto-generated method stub } public void callAnswered(int callId) { System.out.println("Inside Call Answered..."); try { Thread.sleep(200); } catch(Exception e) { System.out.println("Exception After TollFree call...."); } //PhoneCall pcall=Phone.getActiveCall(); try { result = regNum+pinNum; System.out.println("********** Registration and Pin Number result **********:"+result); PhoneCall pcall=Phone.getActiveCall(); System.out.println("Before DTMF Tones...."); pcall.sendDTMFTones(result); System.out.println("After DTMF Tones...."); //Phone.removePhoneListener(this); } catch(Exception e) { System.out.println("After First Dtmf Tones"); } try { Thread.sleep(500); } catch(Exception e) { System.out.println("After Second pause..."); } } public void callConferenceCallEstablished(int callId) { // TODO Auto-generated method stub } public void callDirectConnectConnected(int callId) { // TODO Auto-generated method stub } public void callDirectConnectDisconnected(int callId) { // TODO Auto-generated method stub } public void callDisconnected(int callId) { System.out.println("Inside callDisconnected..."); Phone.removePhoneListener(this); PhoneArguments phoneCallArgs = new PhoneArguments(PhoneArguments.ARG_CALL, "+10555444333", false); Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, phoneCallArgs); UiApplication.getUiApplication().requestBackground (); } public void callEndedByUser(int callId) { System.out.println("Inside callEndedByUser..."); Phone.removePhoneListener(this); UiApplication.getUiApplication().requestBackground (); } public void callFailed(int callId, int pReason) { // TODO Auto-generated method stub } public void callHeld(int callId) { // TODO Auto-generated method stub } public void callIncoming(int callId) { // TODO Auto-generated method stub } public void callInitiated(int callId) { System.out.println("Inside Call Initiated..."); PhoneCall call = Phone.getCall(callId); System.out.println("********Outgoing number is *************:"+call.getDisplayPhoneNumber()); String ph = (String)call.getDisplayPhoneNumber(); EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN, ((char)Keypad.KEY_SEND), KeypadListener.STATUS_NOT_FROM_KEYPAD,100); EventInjector.invokeEvent(ev); } public void callRemoved(int callId) { // TODO Auto-generated method stub } public void callResumed(int callId) { // TODO Auto-generated method stub } public void callWaiting(int callId) { // TODO Auto-generated method stub } public void conferenceCallDisconnected(int callId) { // TODO Auto-generated method stub } public boolean onClose() { int i= Dialog.ask(Dialog.D_YES_NO,"Are you sure you want to quit !"); if(i>0 && i != -1) { System.exit(0); return true; } return false; } public boolean keyDown(int keycode, int time) { System.out.println("Inside KeyDown Method..."); switch (keycode) { case Keypad.KEY_END: return true; //break; case Keypad.KEY_SEND: return true; //break; } return super.keyDown(keycode, time); } }
07-29-2009 09:02 AM
Hi.
Please reread the posts above, they contain important information you have missed.
1) you omitted the listener registration in you application constructor:
Phone.addPhoneListener(this);
2) The application should be the phone listener not the screen
3) you can push your screen on the stack inside callInitiated() -> thatwill be the point of activation of your application
4) use
switch (Keypad.key(aKeyCode))
{
case Keypad.KEY_END:
case Keypad.KEY_SEND:
return true; // consume (ignore) them while your screen is on top.}
inside your keyDown().
07-30-2009 01:33 AM
Now I am able to detecting the entered nuumber in my application.
Also whenever user enters a number from keypad and presses the green key that entered number is dialing...after that my application is invoking.....but I don't want to call entered number while pressing the green key at this time.
I want to Invoke my application first and then I want to call that entered number...
Plz suggest me how to remove the entered number calling...Below is my code.
public class SampleKeypad extends UiApplication { public static String tf="1802107"; public static void main(String[] args) { SampleKeypad theApp = new SampleKeypad(); theApp.enterEventDispatcher(); } public SampleKeypad() { pushScreen(new Express()); } } class Express extends MainScreen implements PhoneListener { public static String str; public static String phno; public static String phNumber; public static AutoTextEditField Num; public static ButtonField dialButton; public static String tf="1802107"; public static String regNum ="911066464646"; public static String pinNum ="8308"; public static String result; public String phone; public static PersistentObject mystoreNum = PersistentStore.getPersistentObject(0xd6dc779737bc
c266L); public static PersistentObject autorun = PersistentStore.getPersistentObject(0x69e39dccfdb4 2804L); public Express() { super(); LabelField title = new LabelField("Welcome",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); setTitle(title); Phone.addPhoneListener(this); } public void callConnected(int callId) { System.out.println("Inside Call Connected..."); try { PhoneCall pcall=Phone.getCall(callId); if(pcall.isOutgoing()) { this.callAnswered(callId); } } catch(Exception e) { System.out.println("Exception inside Call Connected try block...:"); } } public void callAdded(int callId) { // TODO Auto-generated method stub } public void callAnswered(int callId) { System.out.println("Inside Call Answered..."); try { Thread.sleep(200); } catch(Exception e) { System.out.println("Exception After TollFree call...."); } //PhoneCall pcall=Phone.getActiveCall(); try { result = regNum+pinNum; System.out.println("********** Registration and Pin Number result **********:"+result); PhoneCall pcall=Phone.getActiveCall(); System.out.println("Before DTMF Tones...."); pcall.sendDTMFTones(result); System.out.println("After DTMF Tones...."); //Phone.removePhoneListener(this); } catch(Exception e) { System.out.println("After First Dtmf Tones"); } try { Thread.sleep(500); } catch(Exception e) { System.out.println("After Second pause..."); } } public void callConferenceCallEstablished(int callId) { // TODO Auto-generated method stub } public void callDirectConnectConnected(int callId) { // TODO Auto-generated method stub } public void callDirectConnectDisconnected(int callId) { // TODO Auto-generated method stub } public void callDisconnected(int callId) { System.out.println("Inside callDisconnected..."); Phone.removePhoneListener(this); PhoneArguments call2 = new PhoneArguments(PhoneArguments.ARG_CALL, tf,false); Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call2); //UiApplication.getUiApplication().requestBackgrou nd(); } public void callEndedByUser(int callId) { System.out.println("Inside callEndedByUser..."); Phone.removePhoneListener(this); UiApplication.getUiApplication().requestBackground (); } public void callFailed(int callId, int pReason) { // TODO Auto-generated method stub } public void callHeld(int callId) { // TODO Auto-generated method stub } public void callIncoming(int callId) { // TODO Auto-generated method stub } public void callInitiated(int callId) { System.out.println("Inside Call Initiated..."); PhoneCall call = Phone.getCall(callId); System.out.println("********Outgoing number is *************:"+call.getDisplayPhoneNumber()); String ph = (String)call.getDisplayPhoneNumber(); EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN, ((char)Keypad.KEY_SEND), KeypadListener.STATUS_NOT_FROM_KEYPAD,100); EventInjector.invokeEvent(ev); } public void callRemoved(int callId) { // TODO Auto-generated method stub } public void callResumed(int callId) { // TODO Auto-generated method stub } public void callWaiting(int callId) { // TODO Auto-generated method stub } public void conferenceCallDisconnected(int callId) { // TODO Auto-generated method stub } public boolean onClose() { int i= Dialog.ask(Dialog.D_YES_NO,"Are you sure you want to quit !"); if(i>0 && i != -1) { System.exit(0); return true; } return false; } public boolean keyDown(int keycode, int time) { System.out.println("Inside KeyDown Method..."); switch (keycode) { case Keypad.KEY_END: Dialog.alert("Hello..."); return true; //break; case Keypad.KEY_SEND: Dialog.alert("Bye..."); return true; //break; } return super.keyDown(keycode, time); } }
08-03-2009 12:27 AM
08-03-2009 03:31 AM
Please go back to post: steps
And check if step 3 is done OK.
If not, please search the forums for the answer or start another thread because I believe the original question has been answered.
08-03-2009 03:46 AM
If I am pushing my screen inside callInitiated() method....I am getting error like source code not available.
Below is my code for callInitiated() method..plz check it and suggest me.
public void callInitiated(int callId) { System.out.println("Inside Call Initiated..."); PhoneCall call = Phone.getCall(callId); Ui.getUiEngine().popScreen(new Express()); System.out.println("********Outgoing number is *************:"+call.getDisplayPhoneNumber()); EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv
ent.KEY_DOWN, ((char)Keypad.KEY_SEND), KeypadListener.STATUS_NOT_FROM_KEYPAD,100); EventInjector.invokeEvent(ev); }
08-03-2009 03:55 AM
Sorry, this thread is over populated with your code and different questions.
Each question should be posted in a separate thread.
But as a quick hint:
1) you are popping, and not pushing the screen on stack
2) try to send the END key before pushing your screen on stack (otherwise your screen will receive it, and not the dialer)
3) create a new screen object, remember it and push that instance to the stack (so you can later pop it from ouside - if you need to).
4) the pushing and popping must be done on the event thread.