Class ShadowAppTask


  • @Implements(value=android.app.ActivityManager.AppTask.class,
                minSdk=21)
    public class ShadowAppTask
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ShadowAppTask()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void finishAndRemoveTask()
      For tests, marks the task as finished.
      protected android.app.ActivityManager.RecentTaskInfo getTaskInfo()
      For tests, returns the ActivityManager.RecentTaskInfo set using setTaskInfo(RecentTaskInfo).
      boolean hasMovedToFront()
      Returns true if task has been moved to the front.
      boolean isExcludedFromRecents()
      Returns true if task has been excluded from recents.
      boolean isFinishedAndRemoved()
      Returns true if finishAndRemoveTask() has been called before.
      protected void moveToFront()
      For tests, marks the task as moved to the front.
      static android.app.ActivityManager.AppTask newInstance()  
      protected void setExcludeFromRecents​(boolean exclude)
      For tests, marks the task as excluded from recents.
      void setTaskInfo​(android.app.ActivityManager.RecentTaskInfo recentTaskInfo)
      Sets the recentTaskInfo for the task.
      protected void startActivity​(android.content.Context context, android.content.Intent intent, android.os.Bundle options)
      Starts the activity using given context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowAppTask

        public ShadowAppTask()
    • Method Detail

      • newInstance

        public static android.app.ActivityManager.AppTask newInstance()
      • finishAndRemoveTask

        @Implementation
        protected void finishAndRemoveTask()
        For tests, marks the task as finished. Task is not finished when created initially.
        See Also:
        isFinishedAndRemoved()
      • moveToFront

        @Implementation
        protected void moveToFront()
        For tests, marks the task as moved to the front. Task is created and marked as not moved to the front.
        See Also:
        hasMovedToFront()
      • startActivity

        @Implementation
        protected void startActivity​(android.content.Context context,
                                     android.content.Intent intent,
                                     android.os.Bundle options)
        Starts the activity using given context. Started activity can be checked using ShadowContextWrapper.getNextStartedActivity()
        Parameters:
        context - Context with which the activity will be start.
        intent - Intent of the activity to be started.
        options - Extras passed to the activity.
      • setExcludeFromRecents

        @Implementation
        protected void setExcludeFromRecents​(boolean exclude)
        For tests, marks the task as excluded from recents. Current, status can be checked using isExcludedFromRecents().
        Parameters:
        exclude - Whether to exclude from recents.
      • isFinishedAndRemoved

        public boolean isFinishedAndRemoved()
        Returns true if finishAndRemoveTask() has been called before.
      • setTaskInfo

        public void setTaskInfo​(android.app.ActivityManager.RecentTaskInfo recentTaskInfo)
        Sets the recentTaskInfo for the task. getTaskInfo() returns the task info set using this method.
      • hasMovedToFront

        public boolean hasMovedToFront()
        Returns true if task has been moved to the front.
        See Also:
        moveToFront()
      • isExcludedFromRecents

        public boolean isExcludedFromRecents()
        Returns true if task has been excluded from recents.
        See Also:
        setExcludeFromRecents(boolean)