How to identify device in Java code

Hi, I am novice here as well as J2ME.

My question is how can I use a pice of code to identify phone type? For instance, Nokia, Motorola, Sony, & etc. If I want to apply FullCanvas in different phone, I think may be I should know device type before I can do anything else.

Thanks,

In principle, you should be able to call:

System.getProperty("microedition.platform")
  • each different phone model should return a different String value. For instance, my Nokia 6600 returns “Nokia 6600/4.09.1” - the phone model and its software version number.

Due to size constraints, it is nearly always preferable to have different build versions of your app. for the various phones, rather than runtime detection of the phone.

thx folks

I am moving on sprite creation issue. I’d like to have MIDP 2.0 Sprite class feature or similar behavior in MIDP 1.0. Any resource or example to build Sprite class?

MIDP 2.0 Sprite class involves 2 much native call that cannot be used in MIDP 1.0. Sick.

What is a sprite class? ???

for a game developing, in MIDP 2.0 a Sprite class is very easy to handle img movement. Without that, it is very handy to repaint a game screen.

any idea for MIDP 1.0?

Hi!

You can check JTGL library (http://www.jtgl.org) that contains a gaming package nearly compatible with midp2 one.
So you have Surfaces (Layers in Midp2), TiledSurfaces (TiledLayer in Midp2),Sprites and SurfaceManagers (LayerManagers in Midp2) :wink:

Cheers!

It’s pretty easy to make your own Sprite class in MIDP 1.0. All you need is an image with all the animation frames in a row, and then a paint method something like this:


    void paint(Graphics g)
    {
        g.setClip(x, y, width, height);
        g.drawImage(animationFramesImg,
                    x - width * frameIndex[state][frame], y,
                    Graphics.TOP | Graphics.LEFT);
    }

Where state tells whether you’re walking left, walking right, jumping, etc., and frame is just the current index into the animation frame sequence for that state.

For a full example, see Game Animation with Java MIDP at Forum Nokia.

Hmm sounds like something you can do with a array and some magic :slight_smile:
wishes for structs in java

indeed,
in midp :-

less > more

mumm, sounds lot of things to test it out.

Thx folks

Where did you get that icon darcone, maybe useful in a game sprite. :smiley: Just a thought.

The bigass robot? It is part of the images you can choose from here on JGO.