/** This method is used to invoke getEffectivePolicy in the backend */ private void getEffectivePolicy() { if (CommonUtils.isNetworkAvailable(context)) { String ipSaved = Preference.getString(context.getApplicationContext(), Constants.IP); ServerConfig utils = new ServerConfig(); utils.setServerIP(ipSaved); CommonUtils.callSecuredAPI( RegistrationActivity.this, utils.getAPIServerURL() + Constants.POLICY_ENDPOINT + deviceIdentifier, HTTP_METHODS.GET, null, RegistrationActivity.this, Constants.POLICY_REQUEST_CODE); } else { CommonDialogUtils.stopProgressDialog(progressDialog); CommonDialogUtils.showNetworkUnavailableMessage(RegistrationActivity.this); } }
private void registerDevice() { progressDialog = CommonDialogUtils.showPrgressDialog( RegistrationActivity.this, getResources().getString(R.string.dialog_enrolling), getResources().getString(R.string.dialog_please_wait), null); progressDialog.show(); String type = Preference.getString( context, context.getResources().getString(R.string.shared_pref_reg_type)); String username = Preference.getString(context, context.getResources().getString(R.string.username)); try { deviceInfoBuilder.build(type, username); } catch (AndroidAgentException e) { Log.e(TAG, "Error occurred while building the device info payload.", e); } // Check network connection availability before calling the API. if (CommonUtils.isNetworkAvailable(context)) { // Call device registration API. String ipSaved = Preference.getString(context.getApplicationContext(), Constants.IP); ServerConfig utils = new ServerConfig(); utils.setServerIP(ipSaved); CommonUtils.callSecuredAPI( RegistrationActivity.this, utils.getAPIServerURL() + Constants.REGISTER_ENDPOINT, HTTP_METHODS.POST, deviceInfoBuilder.getDeviceInfoPayload(), RegistrationActivity.this, Constants.REGISTER_REQUEST_CODE); } else { CommonDialogUtils.stopProgressDialog(progressDialog); CommonDialogUtils.showNetworkUnavailableMessage(RegistrationActivity.this); } }