设备出厂重置后。 我想检索日历显示名称(通过下面的代码),它返回,没有日历。 但是当打开设备日历应用程序至少一次时,默认电话日历将被正确检索。Sony Xperia T(ST26)日历帐户问题
有没有办法检索日历(尤其是默认),而无需打开设备日历应用程序?
在此先感谢。
这里是设备上获取日历的代码存在:
private Uri getCalendarUri() {
return Uri.parse(Integer.parseInt(Build.VERSION.SDK) > 7 ? "content://com.android.calendar/calendars" : "content://calendar/calendars");
}
private String[] getCalendars(Context context) {
String[] res = null;
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = null;
try {
cursor = contentResolver.query(getCalendarUri(),
Integer.parseInt(Build.VERSION.SDK) > 13 ? new String[]{"_id", "calendar_displayName"} : new String[]{"_id", "displayName"}, null, null, "_id ASC");
if (cursor.getCount() > 0) {
res = new String[cursor.getCount()];
int i = 0;
while (cursor.moveToNext()) {
res[i] = cursor.getString(0) + ": " + cursor.getString(1);
i++;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (cursor != null)
cursor.close();
}
return res;
}
我需要创建标签 “的Xperia” 的帮助。来自索尼开发者网站的报价[我怎么接触](http://developer.sonymobile.com/about/how-do-i-get-in-contact/)。 '对于使用我们的任何手机,工具和SDK的开发人员,我们建议您在Stack Overflow上发布任何 问题。我们有一个开发团队经常监控,贡献 ,并在Stack Overflow上回复关于我们的产品和工具的问题。所以,如果你有一个 的问题,只要确保你用适当的产品名称或“Xperia”标记。那么我们应该是 能够回答你的问题,并为你提供指导。 –