Java 新联系人类和错误-应用程序已停止-Android

Java 新联系人类和错误-应用程序已停止-Android,java,android,android-contacts,Java,Android,Android Contacts,我在Android项目中创建了一个新类,它正在从电话簿中读取联系人。这一类是: public class KontaktBook extends Activity { public void displayContacts() { Toast.makeText(KontaktBook.this, "Name:", Toast.LENGTH_SHORT).show(); ContentResolver cr = getContentResolver();

我在Android项目中创建了一个新类,它正在从电话簿中读取联系人。这一类是:

public class KontaktBook extends Activity {
    public void displayContacts() {
        Toast.makeText(KontaktBook.this, "Name:", Toast.LENGTH_SHORT).show();
        ContentResolver cr = getContentResolver();
        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
                null, null, null, null);
        if (cur.getCount() > 0) {
            while (cur.moveToNext()) {
                String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
                String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                if (Integer.parseInt(cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                    Cursor pCur = cr.query(
                            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                            null,
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
                            new String[]{id}, null);
                    while (pCur.moveToNext()) {
                        String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        Toast.makeText(KontaktBook.this, "Name: " + name + ", Phone No: " + phoneNo, Toast.LENGTH_SHORT).show();
                    }
                    pCur.close();
                }
            }
        }
    }
}
在main类中,我创建了新的KontaktBook对象,如下所示:

    KontaktBook kont = new KontaktBook();
    kont.displayContacts(); 
当我把这个程序放到安卓手机上并导入kont.displayContacts()时

我在电话中收到错误:“不幸的是,申请被停止”

哪里会有问题

当我将这个片段(在metod displayContacts()中)放入Main类(MainActivity)时,问题就消失了——没有问题

PS Logcat显示:

08-10 13:32:15.080  11584-11584/com.example.proj E/dalvikvm﹕ could not disable core file generation for pid 11584: Operation not permitted
08-10 13:32:15.200  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:32:15.200  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:32:15.200  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:32:15.200  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:32:15.200  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:32:15.200  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:32:15.210  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:32:15.210  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:32:15.210  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:32:15.210  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:32:15.210  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:32:15.210  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:32:15.220  11584-11584/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:32:15.220  11584-11584/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:32:15.350  11584-11584/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:32:15.350  11584-11584/com.example.proj W/linker﹕ error:
08-10 13:32:42.140  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:32:42.140  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:32:42.140  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:32:42.140  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:32:42.150  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:32:42.150  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:32:42.160  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:32:42.160  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:32:42.160  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:32:42.160  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:32:42.160  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:32:42.170  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:32:42.170  12032-12032/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:32:42.170  12032-12032/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:32:42.330  12032-12032/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:32:42.330  12032-12032/com.example.proj W/linker﹕ error:
08-10 13:32:42.990  12032-12032/com.example.proj W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41774c50)
08-10 13:39:02.080  12396-12396/com.example.proj E/dalvikvm﹕ could not disable core file generation for pid 12396: Operation not permitted
08-10 13:39:02.210  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:39:02.210  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:39:02.210  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:39:02.210  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:39:02.220  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:39:02.220  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:39:02.230  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:39:02.230  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:39:02.230  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:39:02.230  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:39:02.250  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:39:02.250  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:39:02.250  12396-12396/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:39:02.250  12396-12396/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:39:02.450  12396-12396/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:39:02.450  12396-12396/com.example.proj W/linker﹕ error:
08-10 13:39:22.320  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:39:22.320  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:39:22.320  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:39:22.330  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:39:22.330  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:39:22.330  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:39:22.340  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:39:22.340  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:39:22.340  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:39:22.340  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:39:22.350  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:39:22.350  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:39:22.350  12620-12620/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:39:22.350  12620-12620/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:39:22.500  12620-12620/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:39:22.500  12620-12620/com.example.proj W/linker﹕ error:
08-10 13:39:23.830  12620-12620/com.example.proj W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41774c50)
08-10 13:39:25.670  12620-12620/com.example.proj I/Process﹕ Sending signal. PID: 12620 SIG: 9
08-10 13:40:00.660  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:40:00.660  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:40:00.660  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:40:00.660  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:40:00.670  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:40:00.670  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:40:00.680  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:40:00.680  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:40:00.680  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:40:00.680  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:40:00.690  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:40:00.690  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:40:00.690  12848-12848/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:40:00.690  12848-12848/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:40:00.800  12848-12848/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:40:00.800  12848-12848/com.example.proj W/linker﹕ error:
08-10 13:40:02.170  12848-12848/com.example.proj W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41774c50)
08-10 13:52:03.510  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
08-10 13:52:03.510  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12214: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
08-10 13:52:03.510  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
08-10 13:52:03.510  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 12220: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
08-10 13:52:03.510  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
08-10 13:52:03.510  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 9785: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
08-10 13:52:03.530  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
08-10 13:52:03.530  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 392: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-10 13:52:03.530  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
08-10 13:52:03.530  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 414: Landroid/content/res/TypedArray;.getType (I)I
08-10 13:52:03.540  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
08-10 13:52:03.540  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 355: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:52:03.540  13264-13264/com.example.proj I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
08-10 13:52:03.540  13264-13264/com.example.proj W/dalvikvm﹕ VFY: unable to resolve virtual method 357: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
08-10 13:52:03.750  13264-13264/com.example.proj W/linker﹕ library "libmaliinstr.so" not found
08-10 13:52:03.750  13264-13264/com.example.proj W/linker﹕ error:
08-10 13:52:16.480  13264-13264/com.example.proj W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41774c50)
08-10 13:57:16.560  13264-13264/com.example.proj I/Process﹕ Sending signal. PID: 13264 SIG: 9

您必须使用Intent启动KontaktBook活动,并且您可以在KontaktBook活动的Create方法中调用display Contacts方法,因为您已将其声明为活动。从KontaktBook类中删除extend Activity,以直接从主活动中调用display Contacts方法。

您必须使用Intent启动KontaktBook活动,并且您可以在KontaktBook活动的创建方法中调用display Contacts方法,因为您已将其声明为Activity。从KontaktBook类中删除extend活动,以便从主活动中直接调用display Contacts方法。

谢谢您的回复。我将尝试使用这个意图。顺便问一下,我想问一下,为什么在Android中我不能创建KontaktBook对象?在PC上的Java中,一切正常,我没有得到任何错误…感谢您的回复。我将尝试使用这个意图。顺便问一下,我想问一下,为什么在Android中我不能创建KontaktBook对象?在PC上的Java中,一切正常,我没有得到任何错误。。。