Java Reference
In-Depth Information
public Command get_screenCommand() {
if (screenCommand == null) {
screenCommand = new Command("Add Location", Command.SCREEN, 1);
}
return screenCommand;
}
public Command get_backCommand() {
if (backCommand == null) {
backCommand = new Command("Back", Command.BACK, 1);
}
return backCommand;
}
}
The MIDlet must now declare an instance of WeatherFetcher , so that it can initiate
and cancel requests for weather updates at launch or when you choose a location. The
initialize method takes care of the first case, in which the application requests an
update for a weather forecast at application launch.
The new update method, which the WeatherFetcher instance invokes, must do two
things: update the user interface with the newly obtained forecast, and update the
LocationStore with the new weather data. It silently ignores any failures to update the
LocationStore , under the assumption that the old cached data is likely good enough, and
subsequent views of the same location will refetch the weather forecast data anyway.
The MIDlet's main command handler commandAction must react when you choose a
new location by cancelling any pending operation and creating a new Fetcher for the
newly selected location, initiating a new network request.
Finally, exiting the MIDlet should dismiss the network operation; this is done by both
destroyApp , which the application manager will invoke if the device must terminate the
application, and exitMIDlet , which the user interface itself invokes.
Securing Your HTTP Transaction with HTTPS
While HTTP has many advantages as an application-layer protocol, security's not one
of them. Sharing information over HTTP is like talking in a crowded restaurant; the
only security you get is through obscurity, and that's not really security at all. To meet
the needs of secure applications such as e-commerce, there's the HTTPS protocol,
which is simply HTTP implemented over a secure socket connection such as TLS.
HTTPS provides both client/server authentication through certificates and encryption
of the end-to-end communication using a mutually agreed-upon protocol, defending it
against many kinds of attacks, such as man-in-the-middle and eavesdropping attacks.
Required by MIDP 2.0, HTTPS is an important addition to the Java ME platform that
finds use in many applications.
 
Search WWH ::




Custom Search