views:

2043

answers:

4

I'm creating a indoor navigation application (with the intention that a user can store maps for different buildings in the phones file system). The application starts up by asking the user to select a map for the desired building. Once this has been selected, a file parser would be used to parse and convert the map data from the file. While this is happening, i created a wait screen saying please wait... and also put up a loading/processing image which is a gif. But when i run this in Sun's WTK emulator, the gif doesn't change, it becomes a static picture. By the way, I'm using Netbeans 6.1 for this. Any ideas? Thanks a lot.

+2  A: 

Animated gifs are not supported in MIDP by default so if you really want to play an animated gif you need to use MMAPI for that. I suggest you split up the animation into separate files and do the animation manualy. That is the most poratble way.

This code lets you play an animated gif at the end

InputStream is = getClass().getResourceAsStream("/OceanFish.gif");
DataInputStream di = new DataInputStream(is);
StaticAnimation simage = StaticAnimation.createAnimation(di);

but again I would not suggest it since it is not very portable.

Honza
A: 

Thanks man. Just implemented the code. StaticAnimation class isn't compatible with J2ME. I'm searching for one thats compatible and does the same function.

I'm thinking of using Sprite but do you know any classes that would do the same function. Thanks.

CSFYPMAIL
+1  A: 

Even gif image handling is not supported on older phones as it is stated on a Nokia forum.

However an article in Dr. Dobb's Journal gives a solution on "Displaying GIF Images on J2ME Mobile Phones" using a freely available GifEncoder.java class. Its J2ME port is available from the same page here.

rics
A: 

Maybe not the ideal solution, but you could always extract the gif animation frames to a png formatted sprite sheet and then use the Sprite class to handle the animation. This would be much more portable as the Sprite class is part of the MIDP 2 standard.

Fostah