import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
import javax.microedition.media.*;
public class TipeMediaProtokol extends MIDlet
implements CommandListener {
private Display display;
private Form form;
private StringBuffer sb;
private final Command cmdKeluar =
new Command("Keluar", Command.EXIT, 1);
public TipeMediaProtokol() {
display = Display.getDisplay(this);
form = new Form("Tipe Media & Protokol");
form.addCommand(cmdKeluar);
form.setCommandListener(this);
}
public void startApp() {
sb = getMediaContentsAndProtocols();
StringItem si = new StringItem(null, sb.toString());
form.append(si);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
destroyApp(false);
notifyDestroyed();
}
}
private StringBuffer getMediaContentsAndProtocols() {
StringBuffer temp = new StringBuffer();
String[] tipeMedia = Manager.getSupportedContentTypes(null);
for (int i=0; i<tipeMedia.length; i++) {
String[] protokol =
Manager.getSupportedProtocols(tipeMedia[i]);
for (int j=0; j<protokol.length; j++) {
temp.append(tipeMedia[i] + ":" + protokol[j] + "\n");
}
}
return temp;
}
}
No comments:
Post a Comment