private String checkAnr() { ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.ProcessErrorStateInfo> errorStateInfos = activityManager.getProcessesInErrorState(); if (errorStateInfos != null) { for (ActivityManager.ProcessErrorStateInfo info : errorStateInfos) { if (info.condition == ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING) { StringBuilder anrInfo = new StringBuilder(); anrInfo.append(info.processName) .append("\n") .append(info.shortMsg) .append("\n") .append(info.longMsg); log(TAG, anrInfo.toString()); return anrInfo.toString(); } } } return ""; }
/** * 检查anr * @return */ private String checkAnr() { ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.ProcessErrorStateInfo> errorStateInfos = activityManager.getProcessesInErrorState(); if (errorStateInfos != null) { for (ActivityManager.ProcessErrorStateInfo info : errorStateInfos) { Log.d(TAG, "info.condition------" + info.condition); if (info.condition == ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING) { StringBuilder anrInfo = new StringBuilder(); Log.d(TAG, "info.processName-----" + info.processName); Log.d(TAG, "info.shortMsg-----" + info.shortMsg); Log.d(TAG, "info.longMsg-----" + info.longMsg); //todo 拼接收集上报的信息 anrInfo.append(info.processName) .append("\n") .append(info.shortMsg) .append("\n") .append(info.longMsg); Config.log(TAG, anrInfo.toString()); return anrInfo.toString(); } } } return ""; }
List<ProcessErrorStateInfo> errors = activityMng.getProcessesInErrorState(); if (errors != null) {