연락처 및 캘린더를 다루는 응용 프로그램을 개발 중입니다.Entity Uri를 사용하여 소니 Xperia SP 연락처 정보 얻기
특정 장치 인 Sony Xperia SP를 사용하는 데 어려움을 겪고 있지만 같은 문제가있는 다른 사람을 찾을 수 없습니다.
나는 안드로이드 API의 사용 가능한 엔티티 열린 우리당을 사용하여 표시 이름, 내 기기의 주소록의 전화 번호를 얻으려고 : http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.Entity.html
불행하게도,이 코드는 삼성 갤럭시 S4에 잘 작동 사전, 내가 쿼리하는 모든 세부 사항을 얻을 어디 하지만 소니 Xperia SP에, stacktrace에 의해 설명 된 illegalargumentexception을 받고 있어요 : 열 이름 표시 이름이 잘못되었습니다. 실제로, 필드
ContentResolver cr = context.getContentResolver();
Uri rawUri = RawContacts.CONTENT_URI;
String[] rawProjection = { RawContacts._ID };
String rawSelection = RawContacts.ACCOUNT_NAME + " = ? AND " + RawContacts.ACCOUNT_TYPE + " = ?";
String[] rawSelectionArgs = new String[] { account.name, account.type };
Cursor rawCursor = cr.query(rawUri, rawProjection, rawSelection, rawSelectionArgs, null);
while (rawCursor.moveToNext()) {
long contactId = rawCursor.getLong(0);
Uri entityUri = Uri.withAppendedPath(ContentUris.withAppendedId(rawUri, contactId), Entity.CONTENT_DIRECTORY);
String[] entityProjection = new String[] { Data.DISPLAY_NAME, CommonDataKinds.Phone.NORMALIZED_NUMBER };
String entitySelection = Entity.MIMETYPE + " = ?";
String[] entitySelectionArgs = new String[] { CommonDataKinds.Phone.CONTENT_ITEM_TYPE };
Cursor entityCursor = cr.query(entityUri, entityProjection, entitySelection, entitySelectionArgs, null);
while (entityCursor.moveToNext()) {
String name = entityCursor.getString(entityCursor.getColumnIndex(Data.DISPLAY_NAME));
String number = entityCursor.getString(entityCursor.getColumnIndex(CommonDataKinds.Phone.NORMALIZED_NUMBER));
}
entityCursor.close();
}
나는 필드가이 쿼리에 의해 반환되는 것을 찾기 위해, 널 (null)로 내 entityQuery의 투사를 넣어 시도했습니다, 그리고 : 아래
내가 사용하고 코드입니다 반환 된 장치에서 같은 depeding되지 않습니다누구도 이러한 필드가 Sony Xperia SP에 표시되지 않는 이유와 내가 사용할 수있는 해결 방법을 알고 있습니까?
제발, 제 질문을 읽어 보셨습니까? 대답은 완전히 벗어났다. 나는 내 코드가 갤럭시 S4에서 작동하고 있다고 말했다. 만약 내가 허락을받지 않았다면, 그렇게되지는 않을 것이다. – tchoum