IT tutorials
 
Mobile
 

Java ME on Symbian OS : Handling Transitions Between Foreground and Background

4/16/2013 9:37:53 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Since Symbian OS is a multitasking operating system, the Application Management Software (AMS) can move your MIDlet to the background to allow another application to execute concurrently. After a while, your MIDlet may then be sent back to the foreground.

In S60 5th Edition and 3rd Edition FP2 devices, the MIDlet lifecycle methods are not called by default. To request the AMS to invoke MIDlet.startApp() and MIDlet.pauseApp(), you need to add the Nokia-MIDlet-Background-Event[] proprietary JAD attribute with the value "pause". By default, the attribute value is "run" and pauseApp() and startApp() are not called by the AMS. An alternative way to deal with the MIDlet lifecycle methods not being invoked is to override the Canvas.hideNotify() method, which is called when the MIDlet is sent to the background, and the Canvas.showNotify() method, which is called when it is moved to the foreground.

[] www.forum.nokia.com/document/Java_ME_Developers_Library

What you should ensure is the handling of state switching in both cases so that your application behaves similarly on Symbian smartphones from different vendors. A possible solution would be to decouple the handling of state switching from the specific notification events to handle them in a separate location.

public class StateHandler{

  public synchronized void handleSwitchToBackground(){
    background = true;
    // TODO: handle switching to background
  }
  public synchronized void handleSwitchToForeground(){
    background = false;
    // TODO: handle switching to foreground
  }
}

Then, MIDlet lifecycle methods delegate the calls to the decoupled location:

public void startApp() {
  handler.handleSwitchToForeground();
}
public void pauseApp() {
  handler.handleSwitchToBackground();
}

Canvas notification methods also delegate the calls to the decoupled location:

protected void hideNotify(){
  handler.handleSwitchToBackground();
}
protected void showNotify(){
  handler.handleSwitchToForeground();
}

In Canvas-based MIDlets, for high-level UI screens, the MIDlet could periodically check Displayable.isShown() on the current Displayable object. For example, a separate thread could check every once in a while (e.g., every second) if the current displayable object is visible. If it is not, the application is moved to the background state and, if it is, the application is moved to the foreground state.

Requesting a return to the foreground is possible but there are differences in the implementation. On some platforms, calling MIDlet.resumeRequest() is required, while on others calling Display.setCurrent() with a displayable object is required. Applications can switch themselves to the background on Nokia devices by calling Display.setCurrent(NULL).

public void goToBackground(){
  // will work on Nokia devices
  Display.getDisplay(this).setCurrent(null);
}

public void returnToForeground(){
  // duplicate action to ensure it is performed on various devices
  this.resumeRequest();
  Display.getDisplay(this).setCurrent(current);
}
 
Others
 
- Java ME on Symbian OS : Handling JSR Fragmentation
- IPad : Using Popular and Critical Apps - Using Bento
- IPad : Using Popular and Critical Apps - Using iTap VNC
- BlackBerry Development : Pushing Data to Internal Users - Browser Push
- BlackBerry Application Data Push : How the Application Data Push Process Works
- Windows Phone 8 : Controls - Data Binding (part 4) - Control Templates
- Windows Phone 8 : Controls - Data Binding (part 3) - Data Binding Errors
- Windows Phone 8 : Controls - Data Binding (part 2) - Improving Scrolling Performance, Binding Formatting, Converters
- Windows Phone 8 : Controls - Data Binding (part 1) - Simple Data Binding, Using a DataTemplate
- iPhone SDK 3 : Making Connections with GameKit and Bonjour - iPhone to iPhone Gaming Via BonjourHelper
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us