无法在诺基亚中访问/阅读SIM电话簿 [英] Can't access/read SIM phonebook in Nokia

查看:103
本文介绍了无法在诺基亚中访问/阅读SIM电话簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在诺基亚5130c-2 XpressMusic上同时访问手机的电话簿和SIM卡电话. 该应用程序运行无误,但仅返回电话的电话簿中的号码.当我使用此代码列出可用的电话簿时

am trying to access both the Phone's phonebook and SIM phonenook on Nokia 5130c-2 XpressMusic. The app runs without errors but it only returns the numbers from the phone's Phonebook. When I list the available phonebooks using this code

String[] all_contact_lists=PIM.getInstance().listPIMLists(PIM.CONTACT_LIST);

它同时显示了电话簿和SIM卡列表. IE 1.电话 2. SIM卡

it gives me both the Phonebook and SIM card lists. i.e 1. Phone 2. SIM

我尝试使用此代码从SIM卡中显式读取,但是它仍然不返回任何内容(即使我在SIM卡中保存了号码). 代码:

I have tried explicitly reading from the SIM card using this code but it still returns nothing(even though I have numbers saved in the SIM card.) Code:

ContactList clist = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY,
                "SIM");

这是我完整的代码::

Here's my complete code::

import javax.microedition.midlet.*;
import javax.microedition.pim.*;
import com.sun.lwuit.*;
import java.util.*;

public class contacts extends MIDlet
{
    private List my_list=new List();
    private String[] names=null;
    public void startApp()
    {
        Display.init(this);
       Form my_form=new Form("Contacts List");       
       String[] all_contact_lists=PIM.getInstance().listPIMLists(PIM.CONTACT_LIST);
       //Iterate through available phonebooks
       for(int db=0; db<all_contact_lists.length; db++)
       {
        try {
            ContactList clist = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY,
                    all_contact_lists[db]);
            Enumeration contacts=clist.items();
            while(contacts.hasMoreElements())
            {
                Contact contact=(Contact)contacts.nextElement();
                try{
                    String phone_contact="";
                    names=contact.getStringArray(Contact.NAME, 0);
                    for(int i=0; i<names.length; i++)
                    {
                        if(names[i]!=null)
                            phone_contact+=" "+names[i];
                    }
                    //my_list.addItem(phone_contact);
                    int phone_numbers=contact.countValues(Contact.TEL);
                    if(phone_numbers>0)
                    {
                         String number=contact.getString(Contact.TEL,0);
                        my_list.addItem(phone_contact+":"+number);
                    }
                    else
                    {
                        my_list.addItem(phone_contact);
                    }
                    //clist.removeContact(contact);
                }
                catch (Throwable t) {
            t.printStackTrace();
            }

            }
        } catch (PIMException ex) {
            ex.printStackTrace();
        }
       }
       //my_list.addItem(all_contact_lists);
       my_list.setRenderingPrototype("WWWWWWWWWWWWWWWWWWWW");
       my_form.addComponent(my_list);
       my_form.show();
       }
    public void pauseApp(){}
    public void destroyApp(boolean unconditional){}


}

推荐答案

如果您使用电话号码发送文字或打电话,则只需一行代码即可完成.现在很明显,电话软件问题可能会影响应用程序访问PIM API的方式.另外,如果电话联系人设置中正在使用的内存设置为SIM(单独),则您将无法访问电话内存中的联系人,反之亦然,请确保两者都在使用.如果您仍然有问题,请尝试此操作

If you are using the phone number for a text or to call you can do that with only one line of code. Its now evident that phone software issues can affect the way the app accesses the PIM API. Also, if memory in use in the phones contact settings is set to SIM(alone), you can't access contacts in phone memory and vice versa, make sure both are in use. Try this if you still have an issue,

//make a text field in LWUIT that is declared globally

PhnNmbr = new TextField();

//set it to only accept phonenumber

PhnNmbr.setConstraint(TextField.PHONENUMBER);

//tell the user how to access phonebook

PhnNmbr.setHint("Press T9 then 'Search' to search phonebook");

//add a button or command 
//that either sends an sms to
//or calls the number in the text field
//or anything else you want to do with it

当用户按下T9时,TextField被认为是带有参数PHONENUMBER的LCDUI文本字段,允许其在Sim和手机内存中搜索联系人,这就是为什么您会注意到Search命令(通常在底部中心)的原因.此外,还要确保将手机使用的内存设置为手机"和"SIM卡".

When the user presses T9, the TextField is considered an LCDUI text field with parameter PHONENUMBER which allows it to search for contacts in both Sim and phone memory, thats why you'll notice a Search command(usually at the bottom center). Also make sure that the memory in use for the phone is set to both Phone and Sim.

这篇关于无法在诺基亚中访问/阅读SIM电话簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆