Download Print this page

A Word About Permissions; Example Code - Motorola A780 Manual To Getting Started

J2me
Hide thumbs Also See for A780:

Advertisement

Navigate to the folder that you saved the files to on your phone by going to the
main menu and opening the "files" application. Click once on the jad file (NOT
the jar file) to install the application. Say ok to any dialogs that may appear and
choose the main menu group that you want the shortcut to your new application to
appear in.
You may now launch your application from the main menu by clicking on its
icon.
Note: Since you don't have a debugging console when you are running
applications on the phone, it is recommended that you catch all exceptions and
call the following method with the toString() of your exception:
public void displayException(String e) {
Alert a = new Alert("error:",e,null,AlertType.ERROR);
a.setTimeout(Alert.FOREVER);
myDisplay.setCurrent(a,titleScreen);
}

7. A word about permissions

When you use various classes in J2ME, you need to make sure you set the
permissions in your JAD file appropriately. You can do this by clicking on the
JAD file in your main project (not the one in "deployed") and going to the
"optional" tab. Under "Midlet Permissions:" add the appropriate permissions
comma separated.
The following are common permissions:
javax.microedition.location.Location
o
com.motorola.file.readaccess
o
com.motorola.file.writeaccess
o
javax.microedition.io.Connector.http
o
com.motorola.phone
o
javax.wireless.messaging.sms.send
o
javax.wireless.messaging.sms.receive
o

8. Example code:

0. HTTP Download:
StringBuffer s = new StringBuffer();
HttpConnection c =
(HttpConnection)Connector.open("http://web.mit.edu/index.ht
ml");
InputStream is = c.openInputStream();
byte b;
while ((b = (byte)is.read()) != -1) {
s.append((char)b);
}

Advertisement

loading