Java (Midlet): Obtain Content Types
//import libraries
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
//define class
public class myContentTypes extends MIDlet implements CommandListener
{
private Form myForm; // form to present info
public void startApp()
{
if (myForm == null)
{
// setup the form
myForm = new Form("Obtain Content Types");
Command exitCommand = new Command("Exit", Command.EXIT, 0);
myForm.addCommand(exitCommand);
myForm.setCommandListener(this);
// get the content types
String[] contentTypes = Manager.getSupportedContentTypes(null);
for (int i = 0; i < contentTypes.length; i++)
{
String[] protocols = Manager.getSupportedProtocols(contentTypes[i]);
for (int j = 0; j < protocols.length; j++)
{
StringItem myString = new StringItem(contentTypes[i] + ": ", protocols[j]);
myForm.append(myString);
}
}
}
Display.getDisplay(this).setCurrent(myForm);
}
public void pauseApp()
{} // pauseApp
public void commandAction(Command c, Displayable s)
{
notifyDestroyed();
} // notifyDestroyed
public void destroyApp(boolean unconditional)
{} // destroyApp
}
This is part of the article
Bluetooth mobile push applications in a location aware context
Submit a Comment