Java Reference
In-Depth Information
Putting the PIM Package to Work
Listing 7-8 shows a sample application that uses the PIM package. It performs two func-
tions: on launch, it inserts two entries into the contacts database, and when you press a
soft key, it lists the names of all the contacts in the contacts database.
Note When running this sample application in the Sun emulator or as an unsigned application on a hand-
set, you'll receive many requests by the AMS asking you for permission to perform each operation. This is
because the MIDlet requires privilege to use the PIM package in order to execute, and it must be packaged
as a signed application to avoid prompting the user before that privilege is used.
Listing 7-8. The PIM Package at Work
package com.apress.rischpater;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import java.util.*;
import javax.microedition.pim.*;
public class PIMExample extends MIDlet implements CommandListener {
public PIMExample() {
try {
verifyPIMSupport();
seed();
}
catch (Exception ex) {
Form mForm = new Form("Exception");
mForm.append(new StringItem(null, ex.toString()));
Command mExitCommand = new Command("Exit", Command.EXIT, 0);
mForm.addCommand(mExitCommand);
mForm.setCommandListener(this);
return;
}
}
 
Search WWH ::




Custom Search