Class ShadowActivity

    • Field Detail

      • realActivity

        @RealObject
        protected android.app.Activity realActivity
    • Constructor Detail

      • ShadowActivity

        public ShadowActivity()
    • Method Detail

      • setApplication

        public void setApplication​(android.app.Application application)
      • callAttach

        public void callAttach​(android.content.Intent intent)
      • callAttach

        public void callAttach​(android.content.Intent intent,
                               @Nullable
                               java.lang.Object lastNonConfigurationInstances)
      • setCallingActivity

        public void setCallingActivity​(android.content.ComponentName activityName)
      • getCallingActivity

        @Implementation
        protected android.content.ComponentName getCallingActivity()
      • setCallingPackage

        public void setCallingPackage​(java.lang.String packageName)
      • getCallingPackage

        @Implementation
        protected java.lang.String getCallingPackage()
      • setDefaultKeyMode

        @Implementation
        protected void setDefaultKeyMode​(int keyMode)
      • getDefaultKeymode

        public int getDefaultKeymode()
      • setResult

        @Implementation
        protected final void setResult​(int resultCode)
      • setResult

        @Implementation
        protected final void setResult​(int resultCode,
                                       android.content.Intent data)
      • getLayoutInflater

        @Implementation
        protected android.view.LayoutInflater getLayoutInflater()
      • getMenuInflater

        @Implementation
        protected android.view.MenuInflater getMenuInflater()
      • findViewById

        @Implementation
        protected android.view.View findViewById​(int id)
        Checks to ensure that thecontentView has been set
        Parameters:
        id - ID of the view to find
        Returns:
        the view
        Throws:
        java.lang.RuntimeException - if the contentView has not been called first
      • getParent

        @Implementation
        protected final android.app.Activity getParent()
      • setParent

        @HiddenApi
        @Implementation
        public void setParent​(android.app.Activity parent)
        Allow setting of Parent fragmentActivity (for unit testing purposes only)
        Parameters:
        parent - Parent fragmentActivity to set on this fragmentActivity
      • onBackPressed

        @Implementation
        protected void onBackPressed()
      • finish

        @Implementation
        protected void finish()
      • finishAndRemoveTask

        @Implementation(minSdk=21)
        protected void finishAndRemoveTask()
      • finishAffinity

        @Implementation(minSdk=16)
        protected void finishAffinity()
      • resetIsFinishing

        public void resetIsFinishing()
      • isFinishing

        @Deprecated
        public boolean isFinishing()
        Deprecated.
        Use Activity.isFinishing() instead.
        Returns whether finish() was called.
      • getWindow

        @Implementation
        protected android.view.Window getWindow()
        Constructs a new Window (a com.android.internal.policy.impl.PhoneWindow) if no window has previously been set.
        Returns:
        the window associated with this Activity
      • setWindow

        public void setWindow​(android.view.Window window)
      • runOnUiThread

        @Implementation
        protected void runOnUiThread​(java.lang.Runnable action)
      • setRequestedOrientation

        @Implementation
        protected void setRequestedOrientation​(int requestedOrientation)
      • getRequestedOrientation

        @Implementation
        protected int getRequestedOrientation()
      • getTaskId

        @Implementation
        protected int getTaskId()
      • startIntentSenderForResult

        @Implementation
        public void startIntentSenderForResult​(android.content.IntentSender intentSender,
                                               int requestCode,
                                               @Nullable
                                               android.content.Intent fillInIntent,
                                               int flagsMask,
                                               int flagsValues,
                                               int extraFlags,
                                               android.os.Bundle options)
                                        throws android.content.IntentSender.SendIntentException
        Throws:
        android.content.IntentSender.SendIntentException
      • reportFullyDrawn

        @Implementation(minSdk=19)
        protected void reportFullyDrawn()
      • getReportFullyDrawn

        public boolean getReportFullyDrawn()
        Returns:
        whether ReportFullyDrawn() methods has been called.
      • getContentView

        public android.view.View getContentView()
        Returns:
        the contentView set by one of the setContentView() methods
      • getResultCode

        public int getResultCode()
        Returns:
        the resultCode set by one of the setResult() methods
      • getLastNonConfigurationInstance

        @Implementation
        protected java.lang.Object getLastNonConfigurationInstance()
      • setLastNonConfigurationInstance

        @Deprecated
        public void setLastNonConfigurationInstance​(java.lang.Object lastNonConfigurationInstance)
      • setCurrentFocus

        public void setCurrentFocus​(android.view.View view)
        Parameters:
        view - View to focus.
      • getCurrentFocus

        @Implementation
        protected android.view.View getCurrentFocus()
      • getPendingTransitionEnterAnimationResourceId

        public int getPendingTransitionEnterAnimationResourceId()
      • getPendingTransitionExitAnimationResourceId

        public int getPendingTransitionExitAnimationResourceId()
      • onCreateOptionsMenu

        @Implementation
        protected boolean onCreateOptionsMenu​(android.view.Menu menu)
      • getOptionsMenu

        public android.view.Menu getOptionsMenu()
        Return the options menu.
        Returns:
        Options menu.
      • clickMenuItem

        public boolean clickMenuItem​(int menuItemResId)
        Perform a click on a menu item.
        Parameters:
        menuItemResId - Menu item resource ID.
        Returns:
        True if the click was handled, false otherwise.
      • callOnActivityResult

        @Deprecated
        public void callOnActivityResult​(int requestCode,
                                         int resultCode,
                                         android.content.Intent resultData)
        Deprecated.
      • internalCallDispatchActivityResult

        public void internalCallDispatchActivityResult​(java.lang.String who,
                                                       int requestCode,
                                                       int resultCode,
                                                       android.content.Intent data)
        For internal use only. Not for public use.
      • attachController

        public <T extends android.app.Activity> void attachController​(ActivityController controller)
        For internal use only. Not for public use.
      • setThrowIntentSenderException

        public void setThrowIntentSenderException​(boolean throwIntentSenderException)
        Sets if startIntentSenderForRequestCode will throw an IntentSender.SendIntentException.
      • receiveResult

        public void receiveResult​(android.content.Intent requestIntent,
                                  int resultCode,
                                  android.content.Intent resultIntent)
      • showDialog

        @Implementation
        protected final void showDialog​(int id)
      • dismissDialog

        @Implementation
        protected final void dismissDialog​(int id)
      • removeDialog

        @Implementation
        protected final void removeDialog​(int id)
      • showDialog

        @Implementation
        protected final boolean showDialog​(int id,
                                           android.os.Bundle bundle)
      • setIsTaskRoot

        public void setIsTaskRoot​(boolean isRoot)
      • isTaskRoot

        @Implementation
        protected final boolean isTaskRoot()
      • getLastShownDialogId

        public java.lang.Integer getLastShownDialogId()
        Returns:
        the dialog resource id passed into Activity.showDialog(int, Bundle) or Activity.showDialog(int)
      • hasCancelledPendingTransitions

        public boolean hasCancelledPendingTransitions()
      • overridePendingTransition

        @Implementation
        protected void overridePendingTransition​(int enterAnim,
                                                 int exitAnim)
      • getDialogById

        public android.app.Dialog getDialogById​(int dialogId)
      • recreate

        @Implementation
        protected void recreate()
      • startManagingCursor

        @Implementation
        protected void startManagingCursor​(android.database.Cursor c)
      • stopManagingCursor

        @Implementation
        protected void stopManagingCursor​(android.database.Cursor c)
      • getManagedCursors

        public java.util.List<android.database.Cursor> getManagedCursors()
      • setVolumeControlStream

        @Implementation
        protected final void setVolumeControlStream​(int streamType)
      • getVolumeControlStream

        @Implementation
        protected final int getVolumeControlStream()
      • requestPermissions

        @Implementation(minSdk=23)
        protected final void requestPermissions​(java.lang.String[] permissions,
                                                int requestCode)
      • startLockTask

        @Implementation(minSdk=21)
        protected void startLockTask()
        Starts a lock task.

        The status of the lock task can be verified using isLockTask() method. Otherwise this implementation has no effect.

      • stopLockTask

        @Implementation(minSdk=21)
        protected void stopLockTask()
        Stops a lock task.

        The status of the lock task can be verified using isLockTask() method. Otherwise this implementation has no effect.

      • isLockTask

        @Deprecated
        public boolean isLockTask()
        Deprecated.
        Use ActivityManager.getLockTaskModeState() instead.
        Returns if the activity is in the lock task mode.
      • setInMultiWindowMode

        public void setInMultiWindowMode​(boolean value)
        Changes state of isInMultiWindowMode() method.
      • isInMultiWindowMode

        @Implementation(minSdk=24)
        protected boolean isInMultiWindowMode()
      • getLastIntentSenderRequest

        public ShadowActivity.IntentSenderRequest getLastIntentSenderRequest()
        Gets the last startIntentSenderForResult request made to this activity.
        Returns:
        The IntentSender request details.
      • getLastRequestedPermission

        public ShadowActivity.PermissionsRequest getLastRequestedPermission()
        Gets the last permission request submitted to this activity.
        Returns:
        The permission request details.