Package

Source Code of Info

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

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.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.pim.Event;
import javax.microedition.pim.EventList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;


public class Info extends MIDlet implements CommandListener {
  public Display display = Display.getDisplay(this);

  protected static Command cmdExit = new Command("Exit", Command.SCREEN, 5);

  protected void startApp() throws MIDletStateChangeException {
    Form f = new Form("Info");
    f.addCommand(cmdExit);

    Calendar calLocal = Calendar.getInstance();
    // calLocal.setTimeZone(TimeZone.getTimeZone("PST"));
    Calendar calUTC = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    // calUTC.setTimeZone();

    f.append("Local time: " + calLocal.getTimeZone().getRawOffset() + "\n");
    f.append("UTC time: " + calUTC.getTimeZone().getRawOffset() + "\n");

    String tz[] = TimeZone.getAvailableIDs();
    for (int i = 0; i < tz.length; i++) {
      f.append(tz[i] + "\n");
    }
   
    Canvas s=new Canvas() {
      protected void paint(Graphics arg0) {
        // TODO Auto-generated method stub
       
      }
    };
    f.append("width="+s.getWidth());
    f.append("h="+s.getHeight());

    /*try {
      EventList events = (EventList) PIM.getInstance().openPIMList(
          PIM.EVENT_LIST, PIM.READ_WRITE);
      if (events.maxCategories() != 0) {
        events.addCategory("TV");
            }
     
      calLocal.set(Calendar.MILLISECOND,0);
      calLocal.set(Calendar.SECOND,0);
      calLocal.set(Calendar.MINUTE,1);
      calLocal.set(Calendar.HOUR_OF_DAY,23);
      cr(events, calLocal.getTime(),"LOCAL");
      calUTC.set(Calendar.MILLISECOND,0);
      calUTC.set(Calendar.SECOND,0);
      calUTC.set(Calendar.MINUTE,2);
      calUTC.set(Calendar.HOUR_OF_DAY,23);
      cr(events, calUTC.getTime(),"UTC");
      
    } catch (Exception ex) {
      ex.printStackTrace();
    }*/

    /*
     * Enumeration rootEnum = FileSystemRegistry.listRoots(); while
     * (rootEnum.hasMoreElements()) { Object root = rootEnum.nextElement();
     * f.append("class="+root.getClass().getName()+"\n");
     * f.append(root.toString()+"\n"); }
     */

    /*
     * String uri = "file:///" + "C:/"; f.append("open '" + uri + "'"); try {
     * FileConnection fc = (FileConnection) Connector.open(uri); f.append(" -
     * ok\n"); } catch (Exception ex) { f.append(" - error:" +
     * ex.getMessage()+"\n"); } uri = "file:///" + "Phone memory/";
     * f.append("open '" + uri + "'"); try { FileConnection fc =
     * (FileConnection) Connector.open(uri); f.append(" - ok\n"); } catch
     * (Exception ex) { f.append(" - error:" + ex.getMessage()+"\n"); }
     */

    f.setCommandListener(this);
    display.setCurrent(f);
  }

 
  protected void cr(EventList events, Date when, String title) throws PIMException {
    final Event event = events.createEvent();
        if (events.isSupportedField(Event.LOCATION))
            event.addString(Event.LOCATION, Event.ATTR_NONE, title);
        if (events.isSupportedField(Event.START))
            event.addDate(Event.START, Event.ATTR_NONE, when.getTime());
        if (events.isSupportedField(Event.END))
            event.addDate(Event.END, Event.ATTR_NONE, when.getTime()+60000);
        if ( events.isSupportedField(Event.SUMMARY))
            event.addString(Event.SUMMARY, Event.ATTR_NONE, title);
        if (events.isSupportedField(Event.ALARM))
            event.addInt(Event.ALARM, Event.ATTR_NONE, 60);
        if (events.maxCategories() != 0 && events.isCategory("TV"))
            event.addToCategory("TV");

        event.commit();
  }
  public void commandAction(Command arg0, Displayable arg1) {
    destroyApp(false);
    notifyDestroyed();
  }

  protected void destroyApp(boolean arg0) {
  }

  protected void pauseApp() {
  }

}
TOP

Related Classes of Info

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.