Android 2.2的联系人生日 [英] Android 2.2 Contact Birthday Date
本文介绍了Android 2.2的联系人生日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从Android 2.2的联系方式得到的生日日期,有人可以帮我一点点的查询。
I am trying to get birthday date from contact details from android 2.2, can someone help me a little bit with the query.
下面是我的code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView contactView = (TextView) findViewById(R.id.contactview);
Cursor cursor = getContacts();
while (cursor.moveToNext()) {
String displayBirthday = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Event.START_DATE));
contactView.append("Birthday: ");
contactView.append(displayBirthday);
contactView.append("\n");
}
}
private Cursor getContacts() {
// Run query
Uri uri = ContactsContract.Data.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Event.CONTACT_ID,
ContactsContract.CommonDataKinds.Event.START_DATE
};
String where =
ContactsContract.Data.MIMETYPE + "= ? AND " +
ContactsContract.CommonDataKinds.Event.TYPE + "=" + ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY;
String[] selectionArgs = new String[] {ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE};
String sortOrder = null;
return managedQuery(uri, projection, where, selectionArgs, sortOrder);
}
好像事情是不对的code,我没有得到屏幕上的任何输出。
It seems like something is wrong with this code, I don't get any output on the screen.
我添加在AndroidManifest.xml
I have add in AndroidManifest.xml
有人可以给我一些暗示什么地方错了我的查询,非常感谢。
Can someone give me some hint what's wrong with my query, thanks a lot.
最好的问候,
约翰尼
Best regards, Johnny
推荐答案
我跑你code和它似乎很好地工作。
I ran your code and it seems to work fine.
下面是输出截图,SGS 2.3.3
here is the output screenshot, SGS 2.3.3
下面是截图:
Here is the Screenshot:
这篇关于Android 2.2的联系人生日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文