android.app.ActivityOptions#abort ( )源码实例Demo

下面列出了android.app.ActivityOptions#abort ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: SafeActivityOptions.java
private void abort() {
    if (mOriginalOptions != null) {
        ActivityOptions.abort(mOriginalOptions);
    }
    if (mCallerOptions != null) {
        ActivityOptions.abort(mCallerOptions);
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: ActivityStarter.java
private void resumeTargetStackIfNeeded() {
    if (mDoResume) {
        mSupervisor.resumeFocusedStackTopActivityLocked(mTargetStack, null, mOptions);
    } else {
        ActivityOptions.abort(mOptions);
    }
    mSupervisor.updateUserStackLocked(mStartActivity.userId, mTargetStack);
}
 
源代码3 项目: android_9.0.0_r45   文件: ActivityStarter.java
private void computeLaunchingTaskFlags() {
    // If the caller is not coming from another activity, but has given us an explicit task into
    // which they would like us to launch the new activity, then let's see about doing that.
    if (mSourceRecord == null && mInTask != null && mInTask.getStack() != null) {
        final Intent baseIntent = mInTask.getBaseIntent();
        final ActivityRecord root = mInTask.getRootActivity();
        if (baseIntent == null) {
            ActivityOptions.abort(mOptions);
            throw new IllegalArgumentException("Launching into task without base intent: "
                    + mInTask);
        }

        // If this task is empty, then we are adding the first activity -- it
        // determines the root, and must be launching as a NEW_TASK.
        if (isLaunchModeOneOf(LAUNCH_SINGLE_INSTANCE, LAUNCH_SINGLE_TASK)) {
            if (!baseIntent.getComponent().equals(mStartActivity.intent.getComponent())) {
                ActivityOptions.abort(mOptions);
                throw new IllegalArgumentException("Trying to launch singleInstance/Task "
                        + mStartActivity + " into different task " + mInTask);
            }
            if (root != null) {
                ActivityOptions.abort(mOptions);
                throw new IllegalArgumentException("Caller with mInTask " + mInTask
                        + " has root " + root + " but target is singleInstance/Task");
            }
        }

        // If task is empty, then adopt the interesting intent launch flags in to the
        // activity being started.
        if (root == null) {
            final int flagsOfInterest = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK
                    | FLAG_ACTIVITY_NEW_DOCUMENT | FLAG_ACTIVITY_RETAIN_IN_RECENTS;
            mLaunchFlags = (mLaunchFlags & ~flagsOfInterest)
                    | (baseIntent.getFlags() & flagsOfInterest);
            mIntent.setFlags(mLaunchFlags);
            mInTask.setIntent(mStartActivity);
            mAddingToTask = true;

            // If the task is not empty and the caller is asking to start it as the root of
            // a new task, then we don't actually want to start this on the task. We will
            // bring the task to the front, and possibly give it a new intent.
        } else if ((mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0) {
            mAddingToTask = false;

        } else {
            mAddingToTask = true;
        }

        mReuseTask = mInTask;
    } else {
        mInTask = null;
        // Launch ResolverActivity in the source task, so that it stays in the task bounds
        // when in freeform workspace.
        // Also put noDisplay activities in the source task. These by itself can be placed
        // in any task/stack, however it could launch other activities like ResolverActivity,
        // and we want those to stay in the original task.
        if ((mStartActivity.isResolverActivity() || mStartActivity.noDisplay) && mSourceRecord != null
                && mSourceRecord.inFreeformWindowingMode())  {
            mAddingToTask = true;
        }
    }

    if (mInTask == null) {
        if (mSourceRecord == null) {
            // This activity is not being started from another...  in this
            // case we -always- start a new task.
            if ((mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) == 0 && mInTask == null) {
                Slog.w(TAG, "startActivity called from non-Activity context; forcing " +
                        "Intent.FLAG_ACTIVITY_NEW_TASK for: " + mIntent);
                mLaunchFlags |= FLAG_ACTIVITY_NEW_TASK;
            }
        } else if (mSourceRecord.launchMode == LAUNCH_SINGLE_INSTANCE) {
            // The original activity who is starting us is running as a single
            // instance...  this new activity it is starting must go on its
            // own task.
            mLaunchFlags |= FLAG_ACTIVITY_NEW_TASK;
        } else if (isLaunchModeOneOf(LAUNCH_SINGLE_INSTANCE, LAUNCH_SINGLE_TASK)) {
            // The activity being started is a single instance...  it always
            // gets launched into its own task.
            mLaunchFlags |= FLAG_ACTIVITY_NEW_TASK;
        }
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: ActivityStarter.java
private int setTaskFromInTask() {
    // The caller is asking that the new activity be started in an explicit
    // task it has provided to us.
    if (mService.getLockTaskController().isLockTaskModeViolation(mInTask)) {
        Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
        return START_RETURN_LOCK_TASK_MODE_VIOLATION;
    }

    mTargetStack = mInTask.getStack();

    // Check whether we should actually launch the new activity in to the task,
    // or just reuse the current activity on top.
    ActivityRecord top = mInTask.getTopActivity();
    if (top != null && top.realActivity.equals(mStartActivity.realActivity)
            && top.userId == mStartActivity.userId) {
        if ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0
                || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) {
            mTargetStack.moveTaskToFrontLocked(mInTask, mNoAnimation, mOptions,
                    mStartActivity.appTimeTracker, "inTaskToFront");
            if ((mStartFlags & START_FLAG_ONLY_IF_NEEDED) != 0) {
                // We don't need to start a new activity, and the client said not to do
                // anything if that is the case, so this is it!
                return START_RETURN_INTENT_TO_CALLER;
            }
            deliverNewIntent(top);
            return START_DELIVERED_TO_TOP;
        }
    }

    if (!mAddingToTask) {
        mTargetStack.moveTaskToFrontLocked(mInTask, mNoAnimation, mOptions,
                mStartActivity.appTimeTracker, "inTaskToFront");
        // We don't actually want to have this activity added to the task, so just
        // stop here but still tell the caller that we consumed the intent.
        ActivityOptions.abort(mOptions);
        return START_TASK_TO_FRONT;
    }

    if (!mLaunchParams.mBounds.isEmpty()) {
        // TODO: Shouldn't we already know what stack to use by the time we get here?
        ActivityStack stack = mSupervisor.getLaunchStack(null, null, mInTask, ON_TOP);
        if (stack != mInTask.getStack()) {
            mInTask.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE,
                    DEFER_RESUME, "inTaskToFront");
            mTargetStack = mInTask.getStack();
        }

        updateBounds(mInTask, mLaunchParams.mBounds);
    }

    mTargetStack.moveTaskToFrontLocked(
            mInTask, mNoAnimation, mOptions, mStartActivity.appTimeTracker, "inTaskToFront");

    addOrReparentStartingActivity(mInTask, "setTaskFromInTask");
    if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
            + " in explicit task " + mStartActivity.getTask());

    return START_SUCCESS;
}