开发者

ContactsContract.CommonDataKinds and empty contacts list

I am new to Android development (coming from a C# background) and have been working through some examples in a book. I have a question about the following lines of code.

public void onClick(View arg0){
    Intent i = new Intent(android.content.Intent.ACTION_PICK);
    i.setType(ContactsContract.CommonDataKinds.Email.CONTENT_TYPE);
    startActivityForResult(i, request_Code);
}

According to the book, this code will allow the user to pick a contact from the contact's list. And return the selected contact to the calling activity.

My开发者_运维技巧 question is how to check if there are any contacts stored?

Right now, the i.setType... line fails when the contact list is empty or doesn't have any contacts with an email address.

Is there any way of checking the list before making the call? Or is there a way of capturing the exception?

Thanks in advance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜