Frage

Diese Frage bereits eine Antwort hier:

Im Folgenden ist mein Code:

Cursor mCursor = this.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.HAS_PHONE_NUMBER + "==1", null, null);

startManagingCursor(mCursor);

ListAdapter adapter = new SimpleCursorAdapter(this,
    R.layout.two_line_list_item, mCursor, new String[] {
    PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER}, new int[] {R.id.text1, R.id.text2});

setListAdapter(adapter);

Ich bin in der Lage, die DISPLAY_NAME zu sehen, aber wenn ich PhoneLookup.NUMBER hinzufügen, stürzt die Anwendung. Ich habe auch eine Bedingung wählen nur Kontakte hinzugefügt, die eine Telefonnummer unter der Annahme, seine Krachen aufgrund Null-Daten haben. Noch kein Glück. Gibt es irgendwelche Berechtigungen Ich muss hinzufügen, um die Telefonnummer zu bekommen? Ich habe bereits android.permission.READ_CONTACTS in meinem Manifest.

Logcat Ausgabe:

I/ActivityManager(   58): Starting activity: Intent { cmp=fourth.app/.food }
D/AndroidRuntime(  335): Shutting down VM
W/dalvikvm(  335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime(  335): FATAL EXCEPTION: main
E/AndroidRuntime(  335): java.lang.RuntimeException: Unable to start activity ComponentInfo{fourth.app/fourth.app.food}: java.lang.Ille
galArgumentException: column 'number' does not exist
E/AndroidRuntime(  335):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime(  335):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(  335):        at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(  335):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(  335):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  335):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  335):        at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(  335):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  335):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  335):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  335):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(  335):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  335): Caused by: java.lang.IllegalArgumentException: column 'number' does not exist
E/AndroidRuntime(  335):        at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
E/AndroidRuntime(  335):        at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:99)
E/AndroidRuntime(  335):        at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
E/AndroidRuntime(  335):        at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:87)
E/AndroidRuntime(  335):        at fourth.app.food.onCreate(food.java:21)
E/AndroidRuntime(  335):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(  335):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime(  335):        ... 11 more
W/ActivityManager(   58):   Force finishing activity fourth.app/.food
W/ActivityManager(   58):   Force finishing activity fourth.app/.four
W/ActivityManager(   58): Activity pause timeout for HistoryRecord{43f54e88 fourth.app/.food}
War es hilfreich?

Lösung

java.lang.IllegalArgumentException: column 'number' does not exist 

You are using an invalid name of column.

have a look at this question: How to read contacts on Android 2.0

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top