2012-05-02 3 views
0

나는 안드로이드 1.5 API와 함께 일하고 있는데, 그것이 더 이상 사용되지 않지만 클라이언트 요구 사항을 알고 있습니다. 연락처 주소를 읽으려면 다음 코드를 사용하지만 주소 개수가 0이 될 때마다 사용하고 있습니다. 나는 무엇이 문제인지 알 수 없다.안드로이드 1.5 API가 잘못된 출력을 제공합니다

private void getAddress(String _Id) 
{ 
    Cursor curAddress=null; 
    try 
    { 
     String addrWhere = Contacts.ContactMethods.PERSON_ID + " = ? AND " + Contacts.ContactMethods.KIND + " = ?"; 
     String[] addrWhereParams = new String[]{_Id, Contacts.ContactMethods.CONTENT_POSTAL_ITEM_TYPE}; 
     curAddress = _resolver.query(Contacts.ContactMethods.CONTENT_URI, null, addrWhere, addrWhereParams, null); 
     int i=0; 
     int aCount = curAddress.getCount(); 
     String[] aType = new String[aCount]; 
     String[] aAddrss = new String[aCount]; 
     while(curAddress.moveToNext()) 
     { 
      aType[i] = curAddress.getString(curAddress.getColumnIndex(Contacts.ContactMethodsColumns.TYPE)); 
      aAddrss[i] = curAddress.getString(curAddress.getColumnIndex(Contacts.ContactMethodsColumns.DATA)); 
      i++; 
     } 
    } 
    catch (Exception e) 
    { 
     Log.e(StaticVariables.TAG, "getAddress: " + e.getMessage()); 
    } 
    finally 
    { 
     if(curAddress!=null) curAddress.close(); 
    } 
} 
+2

고객이 항상 올바르지 않습니다. :-(내 앱의 경우 1.6 이하를 목표로 한 적이 없었습니다 .1.5는 1.6으로 고정되어있는 수많은 문제가 있으며 두 번째로 G1 (첫 번째 Android 태블릿 기기)이 1.6으로 업그레이드되었습니다. 세 번째로 안드로이드 지원 라이브러리 (Fragments , 등등)은 1.6으로 돌아 간다. 넷째 1000 개의 안드로이드 디바이스 중 3 개가 오늘 1.5를 사용한다. (또한 7은 1.6을 더 사용한다.) – Sparky

답변

0

아래 코드를 사용하면 효과가있다.

curAddress = getContext().getContentResolver().query(Contacts.ContactMethods.CONTENT_URI, null, addrWhere, addrWhereParams, null); 
+0

thnx는 답장을하지만, _resolver는 클래스 생성자에서 이미 초기화되어 있으며, 주요 활동 . – user874480

관련 문제