@Override public void onSuccess(int statusCode, Header[] headers, String datas) { try { // super.onSuccess(statusCode, headers, datas); JSONObject jsonObject = new JSONObject(datas); int status = jsonObject.getInt(AMConstants.NET_DATAS_UPLOAD_STATUS); AMLogger.e(null, "status : " + status); if (0 == status) { SharedPreferences sp = AMApplication.instance.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE); sp.edit().putInt(AMConstants.SP_DEVICE_UPLOAD, 1).commit(); // 设备信息上报完成,直接开始请求config ConfigRequest config = new ConfigRequest(null); config.start(); } } catch (Exception e) { AMLogger.e(null, e.getMessage()); } }
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_USER_PRESENT.equals(action)) { // 解锁 if (!CommonUtils.isLauncher(context)) { // 如果不是launcher则忽略 return; } // 判断广告显示条件 try { ADType adType = ADController.getInstance() .getDisplayADType(AMApplication.instance, EventType.UNLOCK_SCREEN); if (null != adType) { ADTaskBuilder builder = new ADTaskBuilder(); builder.setADType(TaskType.values()[adType.ordinal()], AMApplication.instance, null); builder.build().start(); } } catch (Exception e) { AMLogger.e(null, e.getMessage()); } } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { // 锁屏 SharedPreferences sp = context.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE); boolean wifiConnected = sp.getBoolean(AMConstants.SP_WIFI_CONNECTED, false); boolean charging = sp.getBoolean(AMConstants.SP_CHARGING, false); if (wifiConnected && charging) { // wifi 且 正在充电 // 静默 try { ADType adType = ADController.getInstance().getDisplayADType(AMApplication.instance, EventType.SILENT); if (null != adType) { SilentRequest request = new SilentRequest(null); request.start(); } } catch (Exception e) { AMLogger.e(null, e.getMessage()); } } } }
@Override public void onFailure( int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); AMLogger.e(null, statusCode); }