Overview Screen

链接:

The overview screen (also referred to as the recents screen, recent task list, or recent apps) is a system-level UI that lists recently accessed activities and tasks. 

With the Android 5.0 release (API level 21), multiple instances of the same activity containing different documents may appear as tasks in the overview screen. 

如下图:

Overview Screen_第1张图片

Adding Tasks to the Overview Screen

Using the Intent flag to add a task

Note: The FLAG_ACTIVITY_NEW_DOCUMENT flag replaces the FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET flag, which is deprecated as of Android 5.0 (API level 21).

当你创建了一份“新文档”,如果设置了FLAG_ACTIVITY_MULTIPLE_TASK这个标志,系统总是会创建一个新的任务栈,然后将启动的activity作为任务栈的root activity。

这个设置允许同一份“文档”,在多个任务栈中打开。示例代码:

 public void createNewDocument(View view) {
      final Intent newDocumentIntent = newDocumentIntent();
      if (useMultipleTasks) {
          newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
      }
      startActivity(newDocumentIntent);
  }

  private Intent newDocumentIntent() {
      boolean useMultipleTasks = mCheckbox.isChecked();
      final Intent newDocumentIntent = new Intent(this, NewDocumentActivity.class);
      newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
      newDocumentIntent.putExtra(KEY_EXTRA_NEW_DOCUMENT_COUNTER, incrementAndGet());
      return newDocumentIntent;
  }

  private static int incrementAndGet() {
      Log.d(TAG, "incrementAndGet(): " + mDocumentCounter);
      return mDocumentCounter++;
  }

  

你可能感兴趣的:(Overview Screen)