get the activity that is started by the first instruction, if exists;
return null if the first instruction is a start-transition instruction
519
protected ActivityImpl determineFirstActivity(ProcessDefinitionImpl processDefinition,
      ProcessInstanceModificationBuilderImpl modificationBuilder) {
    AbstractProcessInstanceModificationCommand firstInstruction = modificationBuilder.getModificationOperations().get(0);

    if (firstInstruction instanceof AbstractInstantiationCmd) {
      AbstractInstantiationCmd instantiationInstruction = (AbstractInstantiationCmd) firstInstruction;
      CoreModelElement targetElement = instantiationInstruction.getTargetElement(processDefinition);

      ensureNotNull(NotValidException.class,
          "Element '" + instantiationInstruction.getTargetElementId() + "' does not exist in process " + processDefinition.getId(),
          "targetElement",
          targetElement);

      if (targetElement instanceof ActivityImpl) {
        return (ActivityImpl) targetElement;
      }
      else if (targetElement instanceof TransitionImpl) {
        return (ActivityImpl) ((TransitionImpl) targetElement).getDestination();
      }

    }

    return null;
  }
217049
private boolean getActivityImplicity(final ACTIVITY activity) {
        if (this.activity == ACTIVITY.ALL) {
            return true;
        }

        if ((activity == ACTIVITY.SUBSCRIBE) && (this.activity == ACTIVITY.PUBLISH)) {
            return false;
        } else if ((activity == ACTIVITY.PUBLISH) && (this.activity == ACTIVITY.SUBSCRIBE)) {
            return false;
        } else if (activity == ACTIVITY.ALL && this.getActivity() != ACTIVITY.ALL) {
            return false;
        }
        return true;
    }
589775
public int getOffsetToStart() {
        if (getChildCount() == 0) return -1;

        final View view = getChildAt(0);

        if (view == null) {
            //in some conditions, for exapmle, calling this method when outter activity destroy, may cause npe
            return -1;
        }

        int position = getPosition(view);
        final int idx = findRangeLength(Range.create(position, position));
        if (idx < 0 || idx >= mRangeLengths.size()) {
            return -1;
        }

        int offset = -mOrientationHelper.getDecoratedStart(view);
        for (int i = 0; i < idx; i++) {
            Pair<Range<Integer>, Integer> pair = mRangeLengths.get(i);
            if (pair != null) {
                offset += pair.second;
            }
        }

        return offset;
    }
1331145
@Nullable
    private TryBlock findBlockWithStart(int pc) {

        for (TryBlock block : blocks) {
            if (block.atStartPC(pc)) {
                return block;
            }
        }

        return null;
    }
968181
private boolean toBoundedFirst() throws FetchException {
        if (mStartBound == null) {
            if (!toFirst()) {
                return false;
            }
        } else {
            if (!toFirst(mStartBound.clone())) {
                return false;
            }
            if (!mInclusiveStart) {
                byte[] currentKey = getCurrentKey();
                if (currentKey == null) {
                    return false;
                }
                if (compareKeysPartially(mStartBound, currentKey) == 0) {
                    if (!toNextKey()) {
                        return false;
                    }
                }
            }
        }

        if (mEndBound != null) {
            byte[] currentKey = getCurrentKey();
            if (currentKey == null) {
                return false;
            }
            int result = compareKeysPartially(currentKey, mEndBound);
            if (result >= 0) {
                if (result > 0 || !mInclusiveEnd) {
                    return false;
                }
            }
        }

        return prefixMatches();
    }
1104278
public int start() {
    Preconditions.checkState(match != null, "Have not called find()");
    if (start >= 0) {
      return tokens.get(start).start();
    }
    return -1;
  }
1040063
@Override
  public String getMainActivity() throws AndroidSdkException {
    if (mainActivity == null) {
      try {
        mainActivity = extractApkDetails("launchable-activity: name='(.*?)'");
      } catch (ShellCommandException e) {
        throw new SelendroidException("The main activity of the apk " + apkFile.getName()
            + " cannot be extracted.");
      }
    }
    return mainActivity;
  }
704781
public ActivityInstance getActivityInstance(Long pActivityInstId)
    throws ProcessException, DataAccessException {
        TransactionWrapper transaction=null;
        try {
            transaction = startTransaction();
            return engineImpl.getDataAccess().getActivityInstance(pActivityInstId);
        } catch (DataAccessException e) {
            if (canRetryTransaction(e)) {
                transaction = (TransactionWrapper)initTransactionRetry(transaction);
                return ((ProcessExecutor)getTransactionRetrier()).getActivityInstance(pActivityInstId);
            }
            else
                throw e;
        } catch (SQLException e) {
            if (canRetryTransaction(e)) {
                transaction = (TransactionWrapper)initTransactionRetry(transaction);
                return ((ProcessExecutor)getTransactionRetrier()).getActivityInstance(pActivityInstId);
            }
            else
                throw new ProcessException(0, "Failed to get activity instance", e);
        } finally {
            stopTransaction(transaction);
        }
    }
114302
public static void starthHomeActivity(@Nullable Activity activity) {
		if (activity != null) {
			if (activity.getClass() != AbstractApplication.get().getHomeActivityClass()) {
				Intent intent = new Intent(activity, AbstractApplication.get().getHomeActivityClass());
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				activity.startActivity(intent);
			}
		} else {
			LOGGER.warn("Null activity. Ignoring launch of " + AbstractApplication.get().getHomeActivityClass().getSimpleName());
		}
	}
1130471
public ResourceActivity getBlockingActivity(ResourceActivity activity) {
        ResourceList res = activity.getResourceList();
        for (ResourceActivity a : inProgress)
            if(res.isCollidingWith(a.getResourceList()))
                return a;
        return null;
    }
1122292
@NonNull @MainThread static ActivityScopedCache getOrCreateActivityScopedCache(
      @NonNull Activity activity) {
    if (activity == null) {
      throw new NullPointerException("Activity is null");
    }

    String activityId = activityIdMap.get(activity);
    if (activityId == null) {
      // Activity not registered yet
      activityId = UUID.randomUUID().toString();
      activityIdMap.put(activity, activityId);

      if (activityIdMap.size() == 1) {
        // Added the an Activity for the first time so register Activity LifecycleListener
        activity.getApplication().registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
        if (DEBUG) {
          Log.d(DEBUG_TAG, "Registering ActivityLifecycleCallbacks");
        }
      }
    }

    ActivityScopedCache activityScopedCache = activityScopedCacheMap.get(activityId);
    if (activityScopedCache == null) {
      activityScopedCache = new ActivityScopedCache();
      activityScopedCacheMap.put(activityId, activityScopedCache);
    }

    return activityScopedCache;
  }
96323
private String getActivityStatus(Task mpxj)
   {
      String result;
      if (mpxj.getActualStart() == null)
      {
         result = "Not Started";
      }
      else
      {
         if (mpxj.getActualFinish() == null)
         {
            result = "In Progress";
         }
         else
         {
            result = "Completed";
         }
      }
      return result;
   }
305454
def run(self):
        
        ctx = FSM.Context(self.name, self.device)
        transition_counter = 0
        timeout = self.timeout
        self.log("{} Start".format(self.name))
        while transition_counter < self.max_transitions:
            transition_counter += 1
            try:
                start_time = time()
                if self.init_pattern is None:
                    ctx.event = self.ctrl.expect(self.events, searchwindowsize=self.searchwindowsize, timeout=timeout)
                else:
                    self.log("INIT_PATTERN={}".format(pattern_to_str(self.init_pattern)))
                    try:
                        ctx.event = self.events.index(self.init_pattern)
                    except ValueError:
                        self.log("INIT_PATTERN unknown.")
                        continue
                    finally:
                        self.init_pattern = None

                finish_time = time() - start_time
                key = (ctx.event, ctx.state)
                ctx.pattern = self.events[ctx.event]

                if key in self.transition_table:
                    transition = self.transition_table[key]
                    next_state, action_instance, next_timeout = transition
                    self.log("E={},S={},T={},RT={:.2f}".format(ctx.event, ctx.state, timeout, finish_time))
                    if callable(action_instance) and not isclass(action_instance):
                        if not action_instance(ctx):
                            self.log("Error: {}".format(ctx.msg))
                            return False
                    elif isinstance(action_instance, Exception):
                        self.log("A=Exception {}".format(action_instance))
                        raise action_instance
                    elif action_instance is None:
                        self.log("A=None")
                    else:
                        self.log("FSM Action is not callable: {}".format(str(action_instance)))
                        raise RuntimeWarning("FSM Action is not callable")

                    if next_timeout != 0:  # no change if set to 0
                        timeout = next_timeout
                    ctx.state = next_state
                    self.log("NS={},NT={}".format(next_state, timeout))

                else:
                    self.log("Unknown transition: EVENT={},STATE={}".format(ctx.event, ctx.state))
                    continue

            except EOF:
                raise ConnectionError("Session closed unexpectedly", self.ctrl.hostname)

            if ctx.finished or next_state == -1:
                self.log("{} Stop at E={},S={}".format(self.name, ctx.event, ctx.state))
                return True

        # check while else if even exists
        self.log("FSM looped. Exiting")
        return False
1229207
@ManyToOne(targetEntity = org.openprovenance.prov.sql.QualifiedName.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "ACTIVITY")
    public org.openprovenance.prov.model.QualifiedName getActivity() {
        return activity;
    }
462464
public Activity getActivity() {
        Context context = getContext();
        while (!(context instanceof Activity) && context instanceof ContextWrapper)
            context = ((ContextWrapper) context).getBaseContext();
        if (!(context instanceof Activity))
            throw new IllegalStateException("Expected an activity context, got " + context.getClass().getSimpleName());
        return (Activity) context;
    }
718338
function maybeStart(priv) {
  if (priv.started) {
    return;
  }
  priv.elem.addEventListener(feature.transitionEventName, handleTransitionEnd.bind(null, priv));
  priv.started = true;
}
613212
public Date getStart()
   {
      Date result = null;
      for (ResourceAssignment assignment : m_assignments)
      {
         if (result == null || DateHelper.compare(result, assignment.getStart()) > 0)
         {
            result = assignment.getStart();
         }
      }
      return (result);
   }