0
我正在尝试开发一个android应用程序,其中我需要获取所有日历条目(提醒),保存在手机日历中,我如何获取它们?我可以在android模拟器上做吗?如何在我的应用程序的android中获取保存的提醒
我正在尝试开发一个android应用程序,其中我需要获取所有日历条目(提醒),保存在手机日历中,我如何获取它们?我可以在android模拟器上做吗?如何在我的应用程序的android中获取保存的提醒
我得到这个code.See,它可以帮助你
Cursor cursor = cr.query(Uri.parse("content://calendar/events"), new String[]{ "calendar_id", "title", "description", "dtstart", "dtend", "eventLocation" }, null, null, null);
//Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "name" }, null, null, null);
String add = null;
cursor.moveToFirst();
String[] CalNames = new String[cursor.getCount()];
int[] CalIds = new int[cursor.getCount()];
for (int i = 0; i < CalNames.length; i++) {
CalIds[i] = cursor.getInt(0);
CalNames[i] = "Event"+cursor.getInt(0)+": \nTitle: "+ cursor.getString(1)+"\nDescription: "+cursor.getString(2)+"\nStart Date: "+new Date(cursor.getLong(3))+"\nEnd Date : "+new Date(cursor.getLong(4))+"\nLocation : "+cursor.getString(5);
if(add == null)
add = CalNames[i];
else{
add += CalNames[i];
}
((TextView)findViewById(R.id.calendars)).setText(add);
cursor.moveToNext();
}
cursor.close();
的GData既过时,并与众多Android版本不兼容。
阅读this将有所帮助。
这是无证和不受支持的。谷歌一再告诉你不要使用无证内容提供商。此代码不适用于所有Android版本。此内容提供商甚至可能不存在于任何给定设备上。 Google可能会关闭对这个内容提供商的访问权限,就像他们与其他人一样。请使用Google日历GData API来操作用户的Google日历。 – CommonsWare