code: private String escape(String rawActivityName) {
          boolean lastIsUnderScore = false;
          StringBuffer sb = new StringBuffer();
          for (int i=0; i<rawActivityName.length(); i++) {
              char ch = rawActivityName.charAt(i);
              if (Character.isLetterOrDigit(ch)) {
                  sb.append(ch);
                  lastIsUnderScore = false;
              } else if (!lastIsUnderScore) {
                  sb.append(UNDERSCORE);
                  lastIsUnderScore = true;
              }
          }
          return sb.toString();
      }
docs: Replaces space characters in the activity name with underscores.
  @param rawActivityName
  @return the escaped activity name