Code sample: List smart card drivers
import net.rim.device.api.smartcard.SmartCardFactory;
import net.rim.device.api.smartcard.SmartCard;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class ListSmartCards extends UiApplication
{
public static void main(String args[])
{
ListSmartCards app = new ListSmartCards();
app.enterEventDispatcher();
}
public ListSmartCards()
{
HomeScreen hs = new HomeScreen();
pushScreen(hs);
}
}
class HomeScreen extends MainScreen
{
public HomeScreen()
{
int numCards = SmartCardFactory.getNumSmartCards();
SmartCard[] smartCards = SmartCardFactory.getSmartCards();
int len = smartCards.length;
StringBuffer sbCards = new StringBuffer();
for(int i=0;i<len;i++)
{
sbCards.append(smartCards[i].getLabel() + '\n');
}
LabelField msg = new LabelField("There are " + Integer.toString(numCards)
+ " smart card drivers installed on this device:\n");
LabelField msgCards = new LabelField(sbCards.toString());
add(msg);
add(msgCards);
}
}
Previous topic: Code samples