1
Google tutorial의 샘플 코드를 사용하고 있습니다. 투영은 내가 수집하고자하는 데이터를 지정하는 곳입니다. 전화 번호를으로 지정하려면 어떻게합니까? Google의 샘플은 전화 번호를받지 않습니다. 전화 번호를 얻으려는 것이므로 Phone.NUMBER
필드를 추가합니다. 하지만 그렇게하면 앱이 항상 다운됩니다. 여기 내 투영입니다. 이 URI가 CommonDataKinds.Phone.NUMBER
필드를 받고 지원하지 않기 때문에 여기에 android : projection crash의 연락처 로더에서 전화 번호 받기
// The projection for the CursorLoader query. This is a list of columns that the Contacts
// Provider should return in the Cursor.
@SuppressLint("InlinedApi")
final static String[] PROJECTION = {
// The contact's row id
Contacts._ID,
// A pointer to the contact that is guaranteed to be more permanent than _ID. Given
// a contact's current _ID value and LOOKUP_KEY, the Contacts Provider can generate
// a "permanent" contact URI.
Contacts.LOOKUP_KEY,
// In platform version 3.0 and later, the Contacts table contains
// DISPLAY_NAME_PRIMARY, which either contains the contact's displayable name or
// some other useful identifier such as an email address. This column isn't
// available in earlier versions of Android, so you must use Contacts.DISPLAY_NAME
// instead.
Utils.hasHoneycomb() ? Contacts.DISPLAY_NAME_PRIMARY : Contacts.DISPLAY_NAME,
// In Android 3.0 and later, the thumbnail image is pointed to by
// PHOTO_THUMBNAIL_URI. In earlier versions, there is no direct pointer; instead,
// you generate the pointer from the contact's ID value and constants defined in
// android.provider.ContactsContract.Contacts.
Utils.hasHoneycomb() ? Contacts.PHOTO_THUMBNAIL_URI : Contacts._ID,
// The sort order column for the returned Cursor, used by the AlphabetIndexer
SORT_ORDER,
// Contacts.HAS_PHONE_NUMBER,
//
CommonDataKinds.Phone.NUMBER,
};
// The query column numbers which map to each value in the projection
final static int ID = 0;
final static int LOOKUP_KEY = 1;
final static int DISPLAY_NAME = 2;
final static int PHOTO_THUMBNAIL_DATA = 3;
final static int SORT_KEY = 4;
// final static int HAS_PHONE_NUMBER = 5;
final static int PHONE_NUMBER = 5;
}
는 오류 추적을
12-18 10:20:54.299: E/AndroidRuntime(1909): FATAL EXCEPTION: ModernAsyncTask #1
12-18 10:20:54.299: E/AndroidRuntime(1909): java.lang.RuntimeException: An error occured while executing doInBackground()
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.lang.Thread.run(Thread.java:841)
12-18 10:20:54.299: E/AndroidRuntime(1909): Caused by: java.lang.IllegalArgumentException: Invalid column data1
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.content.ContentProviderProxy.query(ContentProviderNative.java:385)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.content.ContentResolver.query(ContentResolver.java:417)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.content.ContentResolver.query(ContentResolver.java:360)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:35)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
12-18 10:20:54.299: E/AndroidRuntime(1909): at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
12-18 10:20:54.299: E/AndroidRuntime(1909): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-18 10:20:54.299: E/AndroidRuntime(1909): ... 3 more