J2ME:跨平台与 PIM 联系

发布于 2024-09-27 03:01:31 字数 1823 浏览 1 评论 0原文

我必须基于从地址簿获取数据来开发解决方案。 这些数据必须保存为文本格式。我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香草可樂 2024-10-04 03:01:31

JSR75 PIM API 具有内置的安全功能,要求应用程序由可信来源进行数字签名。签名可以在 GeoTrust 等网站上完成(我在索尼爱立信 W810 上的 AT&T 上使用过它)。

除了对应用程序进行签名之外,您还需要在应用程序的 JAD 文件中启用权限。 PIM API 可能有以下 6 种权限。

javax.microedition.pim.ContactList.read
javax.microedition.pim.ContactList.write
javax.microedition.pim.EventList.read
javax.microedition.pim.EventList.write
javax.microedition.pim.ToDoList.read
javax.microedition.pim.ToDoList.write

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.

javax.microedition.pim.ContactList.read
javax.microedition.pim.ContactList.write
javax.microedition.pim.EventList.read
javax.microedition.pim.EventList.write
javax.microedition.pim.ToDoList.read
javax.microedition.pim.ToDoList.write
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文