Java Reference
In-Depth Information
Run via OTA is an excellent tool for testing your MIDlet's installation behavior rather than
its runtime behavior. Just remember that you need to package the MIDlet first because the
toolkit's small OTA distributes the MIDlet suite JAR file from the project's bin directory.
PushRegistry contains several other static methods that are related to network registrations.
The getMIDlet() and getFilter() methods return the MIDlet name and filter for a given network
connection string. The listConnections() method returns a string array containing all the
registered network connection strings. Finally, to remove a connection-to-MIDlet mapping,
use unregisterConnection() .
Permissions for Network Connections
MIDP 2.0 includes a security framework that is designed to prevent MIDlets from running up
your phone bill by making unauthorized network connections. As we discussed in Chapter 3,
network access in MIDP is guarded by permissions and protection domains. Here are the
permission names defined by MIDP:
javax.microedition.io.Connector.http
• javax.microedition.io.Connector.https
• javax.microedition.io.Connector.datagram
javax.microedition.io.Connector.datagramreceiver
javax.microedition.io.Connector.socket
• javax.microedition.io.Connector.serversocket
• javax.microedition.io.Connector.ssl
• javax.microedition.io.Connector.comm
javax.microedition.io.PushRegistry
These permissions have names corresponding to the API that they protect. All of these
permissions, except one, protect connection types, which are accessed via the
javax.microedition.io.Connector class, hence the prefix on those permission names. The very
last permission refers to the push registry and shares its name with the PushRegistry class.
When you run a MIDlet suite in the toolkit, it runs in the untrusted domain by default. In
the untrusted domain, HTTP and HTTPS connections are allowed if the user grants permission.
You can see this when you run a MIDlet that attempts a network connection. Figure 10-7 shows
how the emulator asks the user for permission and allows the user to make the decision stick
for the remainder of the session.
You can indicate the necessary and optional permissions used by your MIDlet suite by
using the MIDlet-Permissions and MIDlet-Permissions-Opt descriptor attributes. (In the J2ME
Wireless Toolkit, you can set permissions in the descriptor by choosing Settings, and then
clicking the Permissions tab.)
Search WWH ::




Custom Search