private static final String ACTIVITY_GROUP_ID = "INSERT_ACTIVITY_GROUP_ID_HERE";
public static void runExample(DfaServices dfaServices, DfaSession session, String activityName,
String url, long activityGroupId) throws Exception {
// Request the service.
SpotlightRemote service = dfaServices.get(session, SpotlightRemote.class);
// Set spotlight activity structure.
SpotlightActivity spotActivity = new SpotlightActivity();
spotActivity.setId(0);
spotActivity.setName(activityName);
spotActivity.setActivityGroupId(activityGroupId);
spotActivity.setExpectedUrl(new URL(url).toString());
// The type ID for for a counter activity is 1. See GetActivityTypes.java
spotActivity.setActivityTypeId(1);
// The standard tag method type has an ID of 1. See GetTagMethodTypes.java
spotActivity.setTagMethodTypeId(1);
// Create the spotlight tag activity.
SpotlightActivitySaveResult spotlightActivityResult =
service.saveSpotlightActivity(spotActivity);
// Display new spotlight activity ID.
if (spotlightActivityResult != null) {
System.out.printf("Spotlight activity with ID \"%s\" was created.%n",
spotlightActivityResult.getId());