在LOG中发现抛出异常:Attempt to launch content provider before system ready
try {
callCursor = mContext.getContentResolver().query(myUri, null, selection, null,
CallLog.Calls.DEFAULT_SORT_ORDER);
if (callCursor != null) {
size = callCursor.getCount();
}
} finally {
if (callCursor != null) {
callCursor.close();
}
}
在开机过程中执行以下代码时出错:
callCursor = mContext.getContentResolver().query(myUri, null, selection, null,
CallLog.Calls.DEFAULT_SORT_ORDER);
该问题由于代码缺失catch()造成,以下为补充后的代码:
try {
callCursor = mContext.getContentResolver().query(myUri, null, selection, null,
CallLog.Calls.DEFAULT_SORT_ORDER);
if (callCursor != null) {
size = callCursor.getCount();
}
} catch (Exceptione ) {
} finally {
if (callCursor != null) {
callCursor.close();
}
}