Есть один пример по этому поводу, правда сам делать не пробовал:
private String mediaTypes[];
private final String GIF_MIME_TYPE = "image/gif";
private boolean gifSupported;
// Get the media types to check for support of GIF file display
mediaTypes = Manager.getSupportedContentTypes(null);
int count = mediaTypes.length;
// Check list for GIF MIME type; set support flag if present
gifSupported = false;
for (int i = 0; i < count; i++) {
if (mediaTypes[i] == GIF_MIME_TYPE)
gifSupported = true;
} // end for
Back to article
Listing Two
private static final String READ_OK = 0
String url = "http://www.nosuchsite.net/StarTrek/enterprise.gif";
HttpConnection hC = null;
DataInputStream dS = null;
Image mapImage = null;
// Open the connection as an HTTPConnection; send request
try {
hC = (HttpConnection) Connector.open(url);
hC.setRequestMethod(HttpConnection.GET);
hC.setRequestProperty("IF-Modified-Since",
"10 Nov 2000 17:29:12 GMT");
hC.setRequestProperty("User-Agent","Profile/MIDP-2.0
Configuration/CLDC-1.1");
hC.setRequestProperty("Content-Language", "en-CA");
} catch (IOException e) { } // running without safety net!
// Read the data stream for the returned GIF image
int iByteCount;
iByteCount = (int)hC.getLength();
dS = hC.openDataInputStream();
// Does J2ME implementation support native GIF format decode?
if (gifSupported) {
mapImage = Image.createImage(dS); // Yes, translate data
// into an Image
} else {
// No, do it ourselves: get instance of GIF decoder and decode stream
GifDecoder d = new GifDecoder();
if (d != null) {
int err == d.read(dS);
if (err == READ_OK) {
mapImage = d.getImage();
} //end if
} end if
} // end else
Back to article
Listing Three
// The run method for the class.
public void run() {
int t;
if (gifImage != null) {
while (action) {
int n = d.getFrameCount(); // Get # of frames
for (int i = 0; i < n; i++) { // Loop through all
gifImage = d.getFrame(i); // Get frame i
// Delay duration for frame i in milliseconds
t = d.getDelay(i); // Get frame's delay
repaint();
serviceRepaints();
try {
Thread.sleep(t); // Delay as directed
} catch (Exception ex){}
} // end for
} // end while
} // end if
} // end run