J2ME:跨平台与 PIM 联系
我必须基于从地址簿获取数据来开发解决方案。 这些数据必须保存为文本格式。我使用 Java™ Platform Micro Edition SDK 3.0 对其进行了编码。
<代码>
public void getAddrBook() throws Exception{
addrStr= new StringBuffer("");
pim = PIM.getInstance();
try{
contactList = (ContactList)pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
itemList.removeAllElements();
int kk=0;
for (Enumeration items = contactList.items(); items.hasMoreElements();kk++) {
PIMItem item = (PIMItem)items.nextElement();
itemList.addElement(item);
if (kk>5) break;
//detailed enumeration of fields
int[] fields = item.getPIMList().getSupportedFields();
for (int i = 0; i < fields.length; i++) {
int field = fields[i];
int dataType = item.getPIMList().getFieldDataType(field);
String label = item.getPIMList().getFieldLabel(field);
//checking type of PIMItem
//can be STRING, BOOLEAN, STRING_ARRAY, DATE, INT, BINARY
if (dataType==PIMItem.STRING){
for (int j=0; j
}
//String sValue = item.getString(field, 0);
//System.out.println("["+label+"] - "+sValue);
//System.out.println("["+label+"] - ");//+sValue);
}
}
}
}
catch(PIMException e){
throw new Exception("Some errors with access to address book");
//TODO: check empty list and other
}
}
但此代码仅在模拟器中有效,在真机中无效。 我应该如何使用PIM以文本格式保存数据?
另外,我允许访问通讯录。我认为错误是使用 PIM 结构。 我需要一些工作样本。谁有? (:
I have to develop solution based on getting data from address book.
Those data must be saved into text format. I coded it with Java™ Platform Micro Edition SDK 3.0.
public void getAddrBook() throws Exception{ addrStr= new StringBuffer(""); pim = PIM.getInstance(); try{ contactList = (ContactList)pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY); itemList.removeAllElements(); int kk=0; for (Enumeration items = contactList.items(); items.hasMoreElements();kk++) { PIMItem item = (PIMItem)items.nextElement(); itemList.addElement(item); if (kk>5) break; //detailed enumeration of fields int[] fields = item.getPIMList().getSupportedFields(); for (int i = 0; i < fields.length; i++) { int field = fields[i]; int dataType = item.getPIMList().getFieldDataType(field); String label = item.getPIMList().getFieldLabel(field); //checking type of PIMItem //can be STRING, BOOLEAN, STRING_ARRAY, DATE, INT, BINARY if (dataType==PIMItem.STRING){ for (int j=0; j} //String sValue = item.getString(field, 0); //System.out.println("["+label+"] - "+sValue); //System.out.println("["+label+"] - ");//+sValue); } } } } catch(PIMException e){ throw new Exception("Some errors with access to address book"); //TODO: check empty list and other } }
But this code works only in emulator and doesn't work in real phone.
How should I use PIM for saving data in text format?Also, I allowed access to contact book. I think error is using PIM structure.
I need some working sample. Who has it? (:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSR75 PIM API 具有内置的安全功能,要求应用程序由可信来源进行数字签名。签名可以在 GeoTrust 等网站上完成(我在索尼爱立信 W810 上的 AT&T 上使用过它)。
除了对应用程序进行签名之外,您还需要在应用程序的 JAD 文件中启用权限。 PIM API 可能有以下 6 种权限。
The JSR75 PIM API has security features built-in that require applications to be digitally signed by a trusted source. Signing can be done at sites like GeoTrust (I have used it for AT&T on a Sony Ericsson W810).
In addition to signing the application, you will need to enable permissions in the application's JAD file. The following 6 permissions are possible for the PIM API.