鸿蒙3.0系统,读取手机日历数据报空指针
只发现鸿蒙3.0系统的手机出现这种问题,同手机鸿蒙2.0及其他安卓手机无此问题,可以读取到数据,有没有遇到同样问题的,或者有什么解决思路,感谢解答
问题相关代码
private static String CALENDER_EVENT_URL = "content://com.android.calendar/events";
String selection = "(( " + CalendarContract.Events.DTSTART + " >= "
+ startTime.getTimeInMillis() + " ) AND ( " + CalendarContract.Events.DTSTART
+ " <= "</span> + endTime.<span class="hljs-property">getTimeInMillis() + " ) )";
Cursor cursor = MyApplication.getContext().getContentResolver().query(uri, null, selection, null, null);
while (cursor.moveToNext()) {
// 读取数据
}
运行结果及报错内容
Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference