Java Code Examples for android.app.ActivityOptions#makeBasic()

The following examples show how to use android.app.ActivityOptions#makeBasic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolicyManagementFragment.java    From android-testdpc with Apache License 2.0 6 votes vote down vote up
@TargetApi(VERSION_CODES.P)
private void relaunchInLockTaskMode() {
    ActivityManager activityManager = getContext().getSystemService(ActivityManager.class);

    final Intent intent = new Intent(getActivity(), getActivity().getClass());
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    // Ensure a new task is actually created if not already running in lock task mode
    if (!activityManager.isInLockTaskMode()){
        intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    }

    final ActivityOptions options = ActivityOptions.makeBasic();
    options.setLockTaskEnabled(true);

    try {
        startActivity(intent, options.toBundle());
        getActivity().finish();
    } catch (SecurityException e) {
        showToast("You must first whitelist the TestDPC package for LockTask");
    }
}
 
Example 2
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
public void onStartLaunchBoundsActivity(View view) {
    Log.d(mLogTag, "** starting LaunchBoundsActivity");

    // Define the bounds in which the Activity will be launched into.
    Rect bounds = new Rect(500, 300, 100, 0);

    // Set the bounds as an activity option.
    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchBounds(bounds);

    // Start the LaunchBoundsActivity with the specified options
    Intent intent = new Intent(this, LaunchBoundsActivity.class);
    startActivity(intent, options.toBundle());

}
 
Example 3
Source File: ActivityStartInterceptor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean interceptWorkProfileChallengeIfNeeded() {
    final Intent interceptingIntent = interceptWithConfirmCredentialsIfNeeded(mAInfo, mUserId);
    if (interceptingIntent == null) {
        return false;
    }
    mIntent = interceptingIntent;
    mCallingPid = mRealCallingPid;
    mCallingUid = mRealCallingUid;
    mResolvedType = null;
    // If we are intercepting and there was a task, convert it into an extra for the
    // ConfirmCredentials intent and unassign it, as otherwise the task will move to
    // front even if ConfirmCredentials is cancelled.
    if (mInTask != null) {
        mIntent.putExtra(EXTRA_TASK_ID, mInTask.taskId);
        mInTask = null;
    }
    if (mActivityOptions == null) {
        mActivityOptions = ActivityOptions.makeBasic();
    }

    ActivityRecord homeActivityRecord = mSupervisor.getHomeActivity();
    if (homeActivityRecord != null && homeActivityRecord.getTask() != null) {
        // Showing credential confirmation activity in home task to avoid stopping multi-windowed
        // mode after showing the full-screen credential confirmation activity.
        mActivityOptions.setLaunchTaskId(homeActivityRecord.getTask().taskId);
    }

    final UserInfo parent = mUserManager.getProfileParent(mUserId);
    mRInfo = mSupervisor.resolveIntent(mIntent, mResolvedType, parent.id, 0, mRealCallingUid);
    mAInfo = mSupervisor.resolveActivity(mIntent, mRInfo, mStartFlags, null /*profilerInfo*/);
    return true;
}
 
Example 4
Source File: ApiCompatibilityUtils.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates an ActivityOptions Bundle with basic options and the LaunchDisplayId set.
 * @param displayId The id of the display to launch into.
 * @return The created bundle, or null if unsupported.
 */
public static Bundle createLaunchDisplayIdActivityOptions(int displayId) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return null;

    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchDisplayId(displayId);
    return options.toBundle();
}
 
Example 5
Source File: MainActivity.java    From android-MultiWindowPlayground with Apache License 2.0 5 votes vote down vote up
public void onStartLaunchBoundsActivity(View view) {
    Log.d(mLogTag, "** starting LaunchBoundsActivity");

    // Define the bounds in which the Activity will be launched into.
    Rect bounds = new Rect(500, 300, 100, 0);

    // Set the bounds as an activity option.
    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchBounds(bounds);

    // Start the LaunchBoundsActivity with the specified options
    Intent intent = new Intent(this, LaunchBoundsActivity.class);
    startActivity(intent, options.toBundle());

}