@Override
 public boolean handleErrors(Context context) {
   if (!super.doesAppHasInternetPermission(context)) {
     callback_.onInitFinished(
         null,
         new BranchError("Trouble initializing Branch.", BranchError.ERR_NO_INTERNET_PERMISSION));
     return true;
   }
   return false;
 }
 @Override
 public void handleFailure(int statusCode) {
   if (callback_ != null) {
     JSONObject obj = new JSONObject();
     try {
       obj.put("error_message", "Trouble reaching server. Please try again in a few minutes");
     } catch (JSONException ex) {
       ex.printStackTrace();
     }
     callback_.onInitFinished(obj, new BranchError("Trouble initializing Branch.", statusCode));
   }
 }
  @Override
  public void onRequestSucceeded(ServerResponse resp, Branch branch) {
    try {
      prefHelper_.setDeviceFingerPrintID(
          resp.getObject().getString(Defines.Jsonkey.DeviceFingerprintID.getKey()));
      prefHelper_.setUserURL(resp.getObject().getString(Defines.Jsonkey.Link.getKey()));
      prefHelper_.setLinkClickIdentifier(PrefHelper.NO_STRING_VALUE);

      if (resp.getObject().has(Defines.Jsonkey.Data.getKey())) {
        JSONObject dataObj =
            new JSONObject(resp.getObject().getString(Defines.Jsonkey.Data.getKey()));
        // If Clicked on a branch link
        if (dataObj.has(Defines.Jsonkey.Clicked_Branch_Link.getKey())
            && dataObj.getBoolean(Defines.Jsonkey.Clicked_Branch_Link.getKey())) {

          // Check if there is any install params. Install param will be empty on until click a
          // branch link
          // or When a user logout
          if (prefHelper_.getInstallParams().equals(PrefHelper.NO_STRING_VALUE)) {
            // if clicked on link then check for is Referrable state
            if (prefHelper_.getIsReferrable() == 1) {
              String params = resp.getObject().getString(Defines.Jsonkey.Data.getKey());
              prefHelper_.setInstallParams(params);
            }
          }
        }
      }

      if (resp.getObject().has(Defines.Jsonkey.LinkClickID.getKey())) {
        prefHelper_.setLinkClickID(
            resp.getObject().getString(Defines.Jsonkey.LinkClickID.getKey()));
      } else {
        prefHelper_.setLinkClickID(PrefHelper.NO_STRING_VALUE);
      }

      if (resp.getObject().has(Defines.Jsonkey.Data.getKey())) {
        String params = resp.getObject().getString(Defines.Jsonkey.Data.getKey());
        prefHelper_.setSessionParams(params);
      } else {
        prefHelper_.setSessionParams(PrefHelper.NO_STRING_VALUE);
      }
      if (callback_ != null) {
        callback_.onInitFinished(branch.getLatestReferringParams(), null);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }