Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
New Developer
Posts: 24
Registered: ‎08-07-2008
My Device: Not Specified
Accepted Solution

MIDlet app get kick back to first screen upon call reception

I'm trying to understand why a MIDlet get kick back to the first screen when a user will accept an incoming call. I would I've expect the OS to stay on the current screen.

 

Based on the code below if you navigate up to the second screen (and even a third if there was one) and then call/answer the phone then hang up, you'll get kick to the first screen of the app.

 

Blackberry 8330 v4.3.0.124 (Platform 3.1.0.71)

 

 

package pascal; import javax.microedition.lcdui.Display; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class BBCallHandle extends MIDlet { private static BBCallHandle instance; private Display display; public BBCallHandle() { } public static void exit() { instance.notifyDestroyed(); } protected void startApp() throws MIDletStateChangeException { instance = this; display = Display.getDisplay(this); Form1.getInstance(display).go(null); } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { } protected void pauseApp() { } }

 

package pascal; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; public class Form1 extends Form implements CommandListener { private Display display; private Command backCommand; private Command nextFormCommand; private Displayable previous; public Form1(String title) { super(title); } public static Form1 getInstance(Display display) { Form1 instance = new Form1("Form1"); instance.display = display; instance.initUI(); return instance; } public void go(Displayable previous) { this.previous = previous; display.setCurrent(this); } public void commandAction(Command command, Displayable item) { if (command == backCommand) doBackCommand(); else if (command == nextFormCommand) doNextFormCommand(); } private void doBackCommand() { if (previous != null) display.setCurrent(previous); BBCallHandle.exit(); } private void doNextFormCommand() { Form2.getInstance(display).go(this); } private void initUI() { append("You are in form 1"); addCommand(getBackCommand()); addCommand(getNextFormCommand()); setCommandListener(this); } private Command getBackCommand() { if (backCommand == null) backCommand = new Command("Back", Command.BACK, 0); return backCommand; } private Command getNextFormCommand() { if (nextFormCommand == null) nextFormCommand = new Command("Next", Command.SCREEN, 0); return nextFormCommand; } }

 

package pascal; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; public class Form2 extends Form implements CommandListener { private Display display; private Displayable previous; private Command backCommand; public Form2(String title) { super(title); } public static Form2 getInstance(Display display) { Form2 instance = new Form2("Form2"); instance.display = display; instance.initUI(); return instance; } public void go(Displayable previous) { this.previous = previous; display.setCurrent(this); } public void commandAction(Command command, Displayable item) { if (command == backCommand) doBackCommand(); } private void doBackCommand() { display.setCurrent(previous); } private void initUI() { append("Hello form2"); addCommand(getBackCommand()); setCommandListener(this); } private Command getBackCommand() { if (backCommand == null) backCommand = new Command("Back", Command.BACK, 0); return backCommand; } }

 

 

 

 

 

Developer
Posts: 22
Registered: ‎10-30-2008
My Device: Not Specified

Re: MIDlet app get kick back to first screen upon call reception

Form1.getInstance() is being called from startApp() *and* each time this happens, a new instance of Form1 will be created and set as current i.e. display.setCurrent(new Form1()). Iwould think that getting incoming call will call pauseApp() and when call ends, startApp() is called again.

 

I suggest you use System.out.println to see intances (Form1@1234abcd and Thread.currentThread()) in startApp and other "callbacks".

New Developer
Posts: 24
Registered: ‎08-07-2008
My Device: Not Specified

Re: MIDlet app get kick back to first screen upon call reception

Right on!

 

Thanks.