android 开机异常

it2022-05-05  100

在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(); } }

转载于:https://www.cnblogs.com/setsailwu/archive/2013/02/17/3852264.html


最新回复(0)