public void sendRegistrationId() throws AndroidAgentException {
  DeviceInfo deviceInfo=new DeviceInfo(context);
  DeviceInfoPayload deviceInfoPayload=new DeviceInfoPayload(context);
  deviceInfoPayload.build();
  String replyPayload=deviceInfoPayload.getDeviceInfoPayload();
  String ipSaved=Constants.DEFAULT_HOST;
  String prefIP=Preference.getString(context,Constants.PreferenceFlag.IP);
  if (prefIP != null) {
    ipSaved=prefIP;
  }
  if (ipSaved != null && !ipSaved.isEmpty()) {
    ServerConfig utils=new ServerConfig();
    utils.setServerIP(ipSaved);
    String url=utils.getAPIServerURL(context) + Constants.DEVICE_ENDPOINT + deviceInfo.getDeviceId();
    CommonUtils.callSecuredAPI(context,url,org.wso2.emm.agent.proxy.utils.Constants.HTTP_METHODS.PUT,replyPayload,RegistrationActivity.this,Constants.GCM_REGISTRATION_ID_SEND_CODE);
  }
 else {
    Log.e(TAG,"There is no valid IP to contact the server");
  }
}

public void sendRegistrationId ( ) throws AndroidAgentException { DeviceInfo deviceInfo = new DeviceInfo ( context ) ; DeviceInfoPayload deviceInfoPayload = new DeviceInfoPayload ( context ) ; deviceInfoPayload . build ( ) ; String replyPayload = deviceInfoPayload . getDeviceInfoPayload ( ) ; String ipSaved = Constants . DEFAULT_HOST ; String prefIP = Preference . getString ( context , Constants . PreferenceFlag . IP ) ; if ( prefIP != null ) { ipSaved = prefIP ; } if ( ipSaved != null && ! ipSaved . isEmpty ( ) ) { ServerConfig utils = new ServerConfig ( ) ; utils . setServerIP ( ipSaved ) ; String url = utils . getAPIServerURL ( context ) + Constants . DEVICE_ENDPOINT + deviceInfo . getDeviceId ( ) ; CommonUtils . callSecuredAPI ( context , url , org . wso2 . emm . agent . proxy . utils . Constants . HTTP_METHODS . PUT , replyPayload , RegistrationActivity . this , Constants . GCM_REGISTRATION_ID_SEND_CODE ) ; } else { Log . e ( TAG , "There is no valid IP to contact the server" ) ; } }
this is used to send the registration id to mdm server so that the server can use it as a reference to identify the device when sending messages to google server .
