CompassMidlet.java
/**
* Copyright (c) 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example.compass;
import com.nokia.example.compass.views.CompassView;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;
public class CompassMidlet extends MIDlet
{
private Display display;
private static CompassMidlet self;
private CompassView compassview;
private Alert alert;
public void startApp()
{
if (display == null)
{
alert = new Alert("Information", "", null, AlertType.INFO);
alert.setTimeout(4000);//4 seconds
self = this;
compassview = new CompassView();
display = Display.getDisplay(this);
display.setCurrent(compassview);
}
}
public static CompassMidlet getInstance() {
return self;
}
public void showAlert(String message)
{
showAlert(message, AlertType.INFO);
}
public void showAlert(String message, AlertType type) {
alert.setType(type);
alert.setString(message);
display.setCurrent(alert);
}
public void pauseApp()
{
System.out.println("pause state");
}
public void destroyApp(boolean unconditional)
{
}
public CompassView getCompassView() {
return compassview;
}
public void showCompassView() {
display.setCurrent(compassview);
}
}