无法启动活动组件信息:java.lang.NullPointerException

无法启动活动组件信息:java.lang.NullPointerException,java,android,Java,Android,我正在为我的学位构建一个android应用程序。我需要从电话中获取所有联系人 开始申请(稍后我还需要收到电子邮件等)。所以我用了两门课 敏感度 public class Degree_thesisActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.o

我正在为我的学位构建一个android应用程序。我需要从电话中获取所有联系人 开始申请(稍后我还需要收到电子邮件等)。所以我用了两门课

敏感度

   public class Degree_thesisActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    GetFromPhone gf = new GetFromPhone();
    gf.getContacts();

}
}

GetFromPhone.java

class GetFromPhone extends Activity {

public void getContacts() {
    // TODO Auto-generated method stub


    /**Declare a Contacts Cursor which have a list of all contacts*/
    Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    /**Move while cursor has another istance to process*/
    while(cursor.moveToNext()){
        /**Get the contact name pointed by cursor at that time*/
        cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
        String contactID = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
        /**show the contact pointed.THIS WILL BE MODIFIED FURTHER!!!!*/
                new AlertDialog.Builder(this)
                    .setMessage(contactID)
                    .setNeutralButton("ok", new OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub

                        }
                    })
                    .show();

    }

}
}

但我得到了这个错误:

05-05 15:49:20.060:E/AndroidRuntime(824):java.lang.RuntimeException:无法启动活动组件信息{it.paki.degreethesis/it.paki.degreethesis.Degree\u thesisActivity}:java.lang.NullPointerException


为什么?任何人都可以帮助我?

由于类
GetFromPhone
扩展了
活动
,您不能使用
new
关键字创建类的实例。作为一项
活动
,它需要遵循以下步骤。我认为您需要阅读日志。

请将所有错误张贴在日志中。