Here's a simple midlet that will display the supported media types on a MMAPI device:
Code:
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.midlet.*;
public class SupportedMedia extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
public SupportedMedia () {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
protected void startApp() throws MIDletStateChangeException {
String s = "";
try {
String[] ct = Manager.getSupportedContentTypes("http");
for (int i = 0; i < ct.length; i++) {
s += ct[i] + '\n';
}
} catch (Exception e) {
s = e.toString();
}
TextBox t = new TextBox("Media", s, s.length(), 0);
t.setInitialInputMode("UNEDITABLE");
t.addCommand(exitCommand);
t.setCommandListener(this);
display.setCurrent(t);
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
try {
destroyApp(false);
} catch (MIDletStateChangeException e) {
e.printStackTrace();
}
notifyDestroyed();
}
}
}