code: public static void runExample(
        AdManagerServices adManagerServices, AdManagerSession session, int activityGroupId)
        throws RemoteException {
      // Get the ActivityService.
      ActivityServiceInterface activityService =
          adManagerServices.get(session, ActivityServiceInterface.class);
  
      // Create a daily visits activity.
      Activity dailyVisitsActivity = new Activity();
      dailyVisitsActivity.setName("Activity #" + new Random().nextInt(Integer.MAX_VALUE));
      dailyVisitsActivity.setActivityGroupId(activityGroupId);
      dailyVisitsActivity.setType(ActivityType.DAILY_VISITS);
  
      // Create a custom activity.
      Activity customActivity = new Activity();
      customActivity.setName("Activity #" + new Random().nextInt(Integer.MAX_VALUE));
      customActivity.setActivityGroupId(activityGroupId);
      customActivity.setType(ActivityType.CUSTOM);
  
      // Create the activities on the server.
      Activity[] activities =
          activityService.createActivities(new Activity[] {dailyVisitsActivity, customActivity});
  
      for (Activity createdActivity : activities) {
        System.out.printf(
            "An activity with ID %d, name '%s', and type '%s' was created.%n",
            createdActivity.getId(), createdActivity.getName(), createdActivity.getType());
      }
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @param activityGroupId the ID of the activity group to create the activities for.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.