Connections; Use Http Authentication - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Development Guide
• net.rim.device.api.system.RadioInfo
• java.lang.String
• net.rim.device.api.ui.Field
2.
Invoke RadioInfo.getCurrentNetworkName(). The BlackBerry® device must be connected to a wireless
network for this method to work.
String networkName = RadioInfo.getCurrentNetworkName();
System.out.println ("Network Name: " + networkName );

Connections

Use HTTP authentication

1.
Import the following classes:
• net.rim.device.api.system.CoverageInfo
• javax.microedition.io.Connector
• net.rim.device.api.ui.UiApplication
• net.rim.device.api.ui.component.Dialog
• java.lang.String
2.
Import the following interfaces:
• javax.microedition.io.HttpConnection
• net.rim.device.api.system.CoverageStatusListener
• javax.microedition.io.StreamConnection
3.
Use the CoverageInfo class and CoverageStatusListener interface of the
net.rim.device.api.system package to verify that the BlackBerry device is in wireless network coverage area.
4.
Invoke Connector.open(), using the HTTP location of the protected resource.
5.
Cast and store the returned object as a StreamConnection.
StreamConnection s = (StreamConnection)Connector.open("http://mysite.com/
myProtectedFile.txt");
6.
Cast and store the StreamConnection object as an HTTPConnection object.
HttpConnection httpConn = (HttpConnection)s;
7.
Invoke HttpConnection.getResponseCode().
int status = httpConn.getResponseCode();
8.
Create code to manage an unauthorized HTTP connection attempt.
int status = httpConn.getResponseCode();
switch (status)
case (HttpConnection.HTTP_UNAUTHORIZED);
Connections
55

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment

Table of Contents