简体   繁体   中英

How to Enable a JAVA MIDLET to set as StandBy Wallpaper?

I have developed a Simple Clock App in Java midlet in Netbeans . Now i want to set Java Midlet app as wallpaper in phone.

There are two files in my project. AnimationLoopMidlet : contains startApp() function.

AnimationLoop : to update the time and draw on screen. These are my codes.

AnimationLoopMidlet.java

package mobileapplication1;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*; 
public class AnimationLoopMIDlet extends MIDlet{

    static AnimationLoopMIDlet obj;

 public AnimationLoopMIDlet()
 {
      AnimationLoopMIDlet.obj=this;
 }

    public void startApp() {
          Display.getDisplay(this).setCurrent(new AnimationLoop());


    }     




    public void pauseApp()
        {
    }


    public void destroyApp(boolean unconditional) {

    }

}

AnimationLoop.java

package mobileapplication1;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
import javax.microedition.lcdui.game.GameCanvas;





public class AnimationLoop extends GameCanvas implements Runnable{

   boolean running;
     public AnimationLoop()
     {
         super(false);

         start();
     }
     void start()
     {
            Thread t=new Thread(this);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
     }
     public void run()
     {
         running=true;
         while(running)
         {
             update();
             flushGraphics();
         }
     }









            public void update()
            {
                Graphics g=getGraphics();
                    Date c= new Date(); 
                String s=new String();
                s=""+c;
                g.setColor(0xffffff);
                g.setStrokeStyle(Graphics.SOLID);
                g.fillRect(0,0,240,320);

                g.setColor(0x000000);
                g.setFont(Font.getDefaultFont());

                g.drawString("Day:"+s.substring(0,4),0,14,g.LEFT | g.TOP);
                g.drawString("Month"+s.substring(4,7),0,30,g.LEFT | g.TOP);
                g.drawString("Date:"+s.substring(8,10),0,50,g.LEFT | g.TOP);
                g.drawString("Hour:"+s.substring(11,13),0,70,g.LEFT | g.TOP);
                g.drawString("Minute:"+s.substring(14,16),0,90,g.LEFT | g.TOP);
                g.drawString("Seconds:"+s.substring(17,19),0,120,g.LEFT | g.TOP);
              }      





}

Only few JavaME enabled phones offer this option.

(It did become possible with MIDP3.0 though, but since MIDP3.0 never saw daylight, we're still stuck with MIDP2.1).

You can do it with some Sony Ericsson phones by putting the following attribute in the JAD/MANIFEST:

SEMC-StandbyApplication: Y

This works on devices like Sony Ericsson Aino and Elm and K800.

http://developer.sonymobile.com/downloads/code-example-module/create-standby-midlet-for-java-platform-jp-7-phones/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM