FileDocCategorySizeDatePackage
Window.javaAPI DocAndroid 5.1 API75461Thu Mar 12 22:22:10 GMT 2015android.view

Window

public abstract class Window extends Object
Abstract base class for a top-level window look and behavior policy. An instance of this class should be used as the top-level view added to the window manager. It provides standard UI policies such as a background, title area, default key processing, etc.

The only existing implementation of this abstract class is android.policy.PhoneWindow, which you should instantiate when needing a Window. Eventually that class will be refactored and a factory method added for creating Window instances without knowing about a particular implementation.

Fields Summary
public static final int
FEATURE_OPTIONS_PANEL
Flag for the "options panel" feature. This is enabled by default.
public static final int
FEATURE_NO_TITLE
Flag for the "no title" feature, turning off the title at the top of the screen.
public static final int
FEATURE_PROGRESS
Flag for the progress indicator feature
public static final int
FEATURE_LEFT_ICON
Flag for having an icon on the left side of the title bar
public static final int
FEATURE_RIGHT_ICON
Flag for having an icon on the right side of the title bar
public static final int
FEATURE_INDETERMINATE_PROGRESS
Flag for indeterminate progress
public static final int
FEATURE_CONTEXT_MENU
Flag for the context menu. This is enabled by default.
public static final int
FEATURE_CUSTOM_TITLE
Flag for custom title. You cannot combine this feature with other title features.
public static final int
FEATURE_ACTION_BAR
Flag for enabling the Action Bar. This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.
public static final int
FEATURE_ACTION_BAR_OVERLAY
Flag for requesting an Action Bar that overlays window content. Normally an Action Bar will sit in the space above window content, but if this feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over the window content itself. This is useful if you would like your app to have more control over how the Action Bar is displayed, such as letting application content scroll beneath an Action Bar with a transparent background or otherwise displaying a transparent/translucent Action Bar over application content.

This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the action bar in conjunction with other screen decorations.

As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an ActionBar is in this mode it will adjust the insets provided to {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)} to include the content covered by the action bar, so you can do layout within that space.

public static final int
FEATURE_ACTION_MODE_OVERLAY
Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.
public static final int
FEATURE_SWIPE_TO_DISMISS
Flag for requesting a decoration-free window that is dismissed by swiping from the left.
public static final int
FEATURE_CONTENT_TRANSITIONS
Flag for requesting that window content changes should be animated using a TransitionManager.

The TransitionManager is set using {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set, a default TransitionManager will be used.

public static final int
FEATURE_ACTIVITY_TRANSITIONS
Enables Activities to run Activity Transitions either through sending or receiving ActivityOptions bundle created with {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity, android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation( android.app.Activity, View, String)}.
public static final int
FEATURE_MAX
Max value used as a feature ID
public static final int
PROGRESS_VISIBILITY_ON
Flag for setting the progress bar's visibility to VISIBLE
public static final int
PROGRESS_VISIBILITY_OFF
Flag for setting the progress bar's visibility to GONE
public static final int
PROGRESS_INDETERMINATE_ON
Flag for setting the progress bar's indeterminate mode on
public static final int
PROGRESS_INDETERMINATE_OFF
Flag for setting the progress bar's indeterminate mode off
public static final int
PROGRESS_START
Starting value for the (primary) progress
public static final int
PROGRESS_END
Ending value for the (primary) progress
public static final int
PROGRESS_SECONDARY_START
Lowest possible value for the secondary progress
public static final int
PROGRESS_SECONDARY_END
Highest possible value for the secondary progress
public static final String
STATUS_BAR_BACKGROUND_TRANSITION_NAME
The transitionName for the status bar background View when a custom background is used.
public static final String
NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME
The transitionName for the navigation bar background View when a custom background is used.
protected static final int
DEFAULT_FEATURES
The default features enabled.
public static final int
ID_ANDROID_CONTENT
The ID that the main layout in the XML layout file should have.
private static final String
PROPERTY_HARDWARE_UI
private final android.content.Context
mContext
private android.content.res.TypedArray
mWindowStyle
private Callback
mCallback
private OnWindowDismissedCallback
mOnWindowDismissedCallback
private WindowManager
mWindowManager
private android.os.IBinder
mAppToken
private String
mAppName
private boolean
mHardwareAccelerated
private Window
mContainer
private Window
mActiveChild
private boolean
mIsActive
private boolean
mHasChildren
private boolean
mCloseOnTouchOutside
private boolean
mSetCloseOnTouchOutside
private int
mForcedWindowFlags
private int
mFeatures
private int
mLocalFeatures
private boolean
mHaveWindowFormat
private boolean
mHaveDimAmount
private int
mDefaultWindowFormat
private boolean
mHasSoftInputMode
private boolean
mDestroyed
private final WindowManager.LayoutParams
mWindowAttributes
Constructors Summary
public Window(android.content.Context context)


                              
       
                                                     
           

                                                      
           

                                                        
           

                                                     
           

                                                      
           

                                     
           

                                                                
        
           

                                                                                                                                    
             

                                                                                                                  
               

                                                                                             
             

                                                                                          
             

                          
           

                                           
          

                                          
           

                                   
          

                                   
          

                                                                                      
             

                                        
          

                                                                                              
        
           

                                             
           

                                           
           
    

      
       
                                     
          
    

       
        mContext = context;
        mFeatures = mLocalFeatures = getDefaultFeatures(context);
    
Methods Summary
public abstract voidaddContentView(View view, ViewGroup.LayoutParams params)
Variation on {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} to add an additional content view to the screen. Added after any existing ones in the screen -- existing views are NOT removed.

param
view The desired content to display.
param
params Layout parameters for the view.

public voidaddFlags(int flags)
Convenience function to set the flag bits as specified in flags, as per {@link #setFlags}.

param
flags The flag bits to be set.
see
#setFlags
see
#clearFlags

        setFlags(flags, flags);
    
public voidaddPrivateFlags(int flags)

hide

        setPrivateFlags(flags, flags);
    
voidadjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp)

        CharSequence curTitle = wp.getTitle();
        if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
            wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
            if (wp.token == null) {
                View decor = peekDecorView();
                if (decor != null) {
                    wp.token = decor.getWindowToken();
                }
            }
            if (curTitle == null || curTitle.length() == 0) {
                String title;
                if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
                    title="Media";
                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
                    title="MediaOvr";
                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
                    title="Panel";
                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
                    title="SubPanel";
                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
                    title="AtchDlg";
                } else {
                    title=Integer.toString(wp.type);
                }
                if (mAppName != null) {
                    title += ":" + mAppName;
                }
                wp.setTitle(title);
            }
        } else {
            if (wp.token == null) {
                wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
            }
            if ((curTitle == null || curTitle.length() == 0)
                    && mAppName != null) {
                wp.setTitle(mAppName);
            }
        }
        if (wp.packageName == null) {
            wp.packageName = mContext.getPackageName();
        }
        if (mHardwareAccelerated) {
            wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
        }
    
public abstract voidalwaysReadCloseOnTouchAttr()

hide

public voidclearFlags(int flags)
Convenience function to clear the flag bits as specified in flags, as per {@link #setFlags}.

param
flags The flag bits to be cleared.
see
#setFlags
see
#addFlags

        setFlags(0, flags);
    
public abstract voidcloseAllPanels()

public abstract voidclosePanel(int featureId)

public final voiddestroy()

hide

        mDestroyed = true;
    
public final voiddispatchOnWindowDismissed()

hide

        if (mOnWindowDismissedCallback != null) {
            mOnWindowDismissedCallback.onWindowDismissed();
        }
    
protected voiddispatchWindowAttributesChanged(WindowManager.LayoutParams attrs)
{@hide}

        if (mCallback != null) {
            mCallback.onWindowAttributesChanged(attrs);
        }
    
public ViewfindViewById(int id)
Finds a view that was identified by the id attribute from the XML that was processed in {@link android.app.Activity#onCreate}. This will implicitly call {@link #getDecorView} for you, with all of the associated side-effects.

return
The view if found or null otherwise.

        return getDecorView().findViewById(id);
    
public booleangetAllowEnterTransitionOverlap()
Returns how the transition set in {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit transition of the calling Activity. When true, the transition will start as soon as possible. When false, the transition will wait until the remote exiting transition completes before starting.

return
true when the enter transition should start as soon as possible or false to when it should wait until the exiting transition completes.
attr
ref android.R.styleable#Window_windowAllowEnterTransitionOverlap

 return true; 
public booleangetAllowExitTransitionOverlap()
TODO: remove this.

hide

 return getAllowReturnTransitionOverlap(); 
public booleangetAllowReturnTransitionOverlap()
Returns how the transition set in {@link #setExitTransition(android.transition.Transition)} overlaps with the exit transition of the called Activity when reentering after if finishes. When true, the transition will start as soon as possible. When false, the transition will wait until the called Activity's exiting transition completes before starting.

return
true when the transition should start when possible or false when it should wait until the called Activity's exiting transition completes.
attr
ref android.R.styleable#Window_windowAllowReturnTransitionOverlap

 return true; 
public final WindowManager.LayoutParamsgetAttributes()
Retrieve the current window attributes associated with this panel.

return
WindowManager.LayoutParams Either the existing window attributes object, or a freshly created one if there is none.

        return mWindowAttributes;
    
public final android.view.Window$CallbackgetCallback()
Return the current Callback interface for this window.

        return mCallback;
    
public final android.view.WindowgetContainer()
Return the container for this Window.

return
Window The containing window, or null if this is a top-level window.

        return mContainer;
    
public android.transition.ScenegetContentScene()
Retrieve the {@link Scene} representing this window's current content. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.

This method will return null if the current content is not represented by a Scene.

return
Current Scene being shown or null

        return null;
    
public final android.content.ContextgetContext()
Return the Context this window policy is running in, for retrieving resources and other information.

return
Context The Context that was supplied to the constructor.

        return mContext;
    
public abstract ViewgetCurrentFocus()
Return the view in this Window that currently has focus, or null if there are none. Note that this does not look in any containing Window.

return
View The current View with focus or null.

public abstract ViewgetDecorView()
Retrieve the top-level window decor view (containing the standard window frame/decorations and the client's content inside of that), which can be added as a window to the window manager.

Note that calling this function for the first time "locks in" various window characteristics as described in {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.

return
Returns the top-level window decor view.

public static intgetDefaultFeatures(android.content.Context context)
Return the feature bits set by default on a window.

param
context The context used to access resources

        int features = 0;

        final Resources res = context.getResources();
        if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
            features |= 1 << FEATURE_OPTIONS_PANEL;
        }

        if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
            features |= 1 << FEATURE_CONTEXT_MENU;
        }

        return features;
    
public android.transition.TransitiongetEnterTransition()
Returns the transition used to move Views into the initial scene. The entering Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as entering is governed by changing visibility from {@link View#INVISIBLE} to {@link View#VISIBLE}. If transition is null, entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
the Transition to use to move Views into the initial Scene.
attr
ref android.R.styleable#Window_windowEnterTransition

 return null; 
public android.transition.TransitiongetExitTransition()
Returns the Transition that will be used to move Views out of the scene when starting a new Activity. The exiting Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as exiting is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
the Transition to use to move Views out of the scene when calling a new Activity.
attr
ref android.R.styleable#Window_windowExitTransition

 return null; 
protected final intgetFeatures()
Return the feature bits that are enabled. This is the set of features that were given to requestFeature(), and are being handled by this Window itself or its container. That is, it is the set of requested features that you can actually use.

To do: add a public version of this API that allows you to check for features by their feature ID.

return
int The feature bits.

        return mFeatures;
    
protected final intgetForcedWindowFlags()
Return the window flags that have been explicitly set by the client, so will not be modified by {@link #getDecorView}.

        return mForcedWindowFlags;
    
public abstract LayoutInflatergetLayoutInflater()
Quick access to the {@link LayoutInflater} instance that this Window retrieved from its Context.

return
LayoutInflater The shared LayoutInflater.

protected final intgetLocalFeatures()
Return the feature bits that are being implemented by this Window. This is the set of features that were given to requestFeature(), and are being handled by only this Window itself, not by its containers.

return
int The feature bits.

        return mLocalFeatures;
    
public android.media.session.MediaControllergetMediaController()
Gets the {@link MediaController} that was previously set.

return
The controller which should receive events.
see
#setMediaController(android.media.session.MediaController)
see
android.app.Activity#getMediaController()

        return null;
    
public abstract intgetNavigationBarColor()

return
the color of the navigation bar.

public android.transition.TransitiongetReenterTransition()
Returns the Transition that will be used to move Views in to the scene when returning from a previously-started Activity. The entering Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as exiting is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
The Transition to use to move Views into the scene when reentering from a previously-started Activity.
attr
ref android.R.styleable#Window_windowReenterTransition

 return null; 
public android.transition.TransitiongetReturnTransition()
Returns he Transition that will be used to move Views out of the scene when the Window is preparing to close, for example after a call to {@link android.app.Activity#finishAfterTransition()}. The exiting Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as entering is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.

return
The Transition to use to move Views out of the Scene when the Window is preparing to close.
attr
ref android.R.styleable#Window_windowReturnTransition

 return null; 
public android.transition.TransitiongetSharedElementEnterTransition()
Returns the Transition that will be used for shared elements transferred into the content Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
Transition to use for sharend elements transferred into the content Scene.
attr
ref android.R.styleable#Window_windowSharedElementEnterTransition

 return null; 
public android.transition.TransitiongetSharedElementExitTransition()
Returns the Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
the Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window.
attr
ref android.R.styleable#Window_windowSharedElementExitTransition

 return null; 
public android.transition.TransitiongetSharedElementReenterTransition()
Returns the Transition that will be used for shared elements reentering from a started Activity after it has returned the shared element to it start location. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
the Transition that will be used for shared elements reentering from a started Activity after it has returned the shared element to it start location.
attr
ref android.R.styleable#Window_windowSharedElementReenterTransition

 return null; 
public android.transition.TransitiongetSharedElementReturnTransition()
Returns the Transition that will be used for shared elements transferred back to a calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

return
Transition to use for sharend elements transferred into the content Scene.
attr
ref android.R.styleable#Window_windowSharedElementReturnTransition

 return null; 
public booleangetSharedElementsUseOverlay()
Returns true when shared elements should use an Overlay during shared element transitions or false when they should animate as part of the normal View hierarchy. The default value is true.

return
true when shared elements should use an Overlay during shared element transitions or false when they should animate as part of the normal View hierarchy.
attr
ref android.R.styleable#Window_windowSharedElementsUseOverlay

 return true; 
public abstract intgetStatusBarColor()

return
the color of the status bar.

public longgetTransitionBackgroundFadeDuration()
Returns the duration, in milliseconds, of the window background fade when transitioning into or away from an Activity when called with an Activity Transition.

When executing the enter transition, the background starts transparent and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is 300 milliseconds.

return
The duration of the window background fade to opaque during enter transition.
see
#getEnterTransition()
attr
ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration

 return 0; 
public android.transition.TransitionManagergetTransitionManager()
Retrieve the {@link TransitionManager} responsible for for default transitions in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.

This method will return non-null after content has been initialized (e.g. by using {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.

return
This window's content TransitionManager or null if none is set.
attr
ref android.R.styleable#Window_windowContentTransitionManager

        return null;
    
public abstract intgetVolumeControlStream()

see
android.app.Activity#getVolumeControlStream()

public WindowManagergetWindowManager()
Return the window manager allowing this Window to display its own windows.

return
WindowManager The ViewManager.

        return mWindowManager;
    
public final android.content.res.TypedArraygetWindowStyle()
Return the {@link android.R.styleable#Window} attributes from this window's theme.

        synchronized (this) {
            if (mWindowStyle == null) {
                mWindowStyle = mContext.obtainStyledAttributes(
                        com.android.internal.R.styleable.Window);
            }
            return mWindowStyle;
        }
    
public final booleanhasChildren()

        return mHasChildren;
    
public booleanhasFeature(int feature)
Query for the availability of a certain feature.

param
feature The feature ID to check
return
true if the feature is enabled, false otherwise.

        return (getFeatures() & (1 << feature)) != 0;
    
protected final booleanhasSoftInputMode()
Has the app specified their own soft input mode?

        return mHasSoftInputMode;
    
protected booleanhaveDimAmount()

hide

        return mHaveDimAmount;
    
public voidinjectInputEvent(InputEvent event)
Inject an event to window locally.

param
event A key or touch event to inject to this window.

 
public abstract voidinvalidatePanelMenu(int featureId)

public final booleanisActive()

        return mIsActive;
    
public final booleanisDestroyed()

hide

        return mDestroyed;
    
public abstract booleanisFloating()
Return whether this window is being displayed with a floating style (based on the {@link android.R.attr#windowIsFloating} attribute in the style/theme).

return
Returns true if the window is configured to be displayed floating on top of whatever is behind it.

private booleanisOutOfBounds(android.content.Context context, MotionEvent event)

        final int x = (int) event.getX();
        final int y = (int) event.getY();
        final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
        final View decorView = getDecorView();
        return (x < -slop) || (y < -slop)
                || (x > (decorView.getWidth()+slop))
                || (y > (decorView.getHeight()+slop));
    
public abstract booleanisShortcutKey(int keyCode, KeyEvent event)
Is a keypress one of the defined shortcut keys for this window.

param
keyCode the key code from {@link android.view.KeyEvent} to check.
param
event the {@link android.view.KeyEvent} to use to help check.

public final voidmakeActive()

        if (mContainer != null) {
            if (mContainer.mActiveChild != null) {
                mContainer.mActiveChild.mIsActive = false;
            }
            mContainer.mActiveChild = this;
        }
        mIsActive = true;
        onActive();
    
protected abstract voidonActive()

public abstract voidonConfigurationChanged(android.content.res.Configuration newConfig)
Should be called when the configuration is changed.

param
newConfig The new configuration.

public abstract voidopenPanel(int featureId, KeyEvent event)

public abstract ViewpeekDecorView()
Retrieve the current decor view, but only if it has already been created; otherwise returns null.

return
Returns the top-level window decor or null.
see
#getDecorView

public abstract booleanperformContextMenuIdentifierAction(int id, int flags)

public abstract booleanperformPanelIdentifierAction(int featureId, int id, int flags)

public abstract booleanperformPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)

protected voidremoveFeature(int featureId)

hide
Used internally to help resolve conflicting features.

        final int flag = 1<<featureId;
        mFeatures &= ~flag;
        mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
    
public booleanrequestFeature(int featureId)
Enable extended screen features. This must be called before setContentView(). May be called as many times as desired as long as it is before setContentView(). If not called, no extended features will be available. You can not turn off a feature once it is requested. You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.

param
featureId The desired features, defined as constants by Window.
return
The features that are now set.

        final int flag = 1<<featureId;
        mFeatures |= flag;
        mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
        return (mFeatures&flag) != 0;
    
public abstract voidrestoreHierarchyState(android.os.Bundle savedInstanceState)

public abstract android.os.BundlesaveHierarchyState()

public voidsetAllowEnterTransitionOverlap(boolean allow)
Controls how the transition set in {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit transition of the calling Activity. When true, the transition will start as soon as possible. When false, the transition will wait until the remote exiting transition completes before starting.

param
allow true to start the enter transition when possible or false to wait until the exiting transition completes.
attr
ref android.R.styleable#Window_windowAllowEnterTransitionOverlap

public voidsetAllowExitTransitionOverlap(boolean allow)
TODO: remove this.

hide

        setAllowReturnTransitionOverlap(allow);
    
public voidsetAllowReturnTransitionOverlap(boolean allow)
Controls how the transition set in {@link #setExitTransition(android.transition.Transition)} overlaps with the exit transition of the called Activity when reentering after if finishes. When true, the transition will start as soon as possible. When false, the transition will wait until the called Activity's exiting transition completes before starting.

param
allow true to start the transition when possible or false to wait until the called Activity's exiting transition completes.
attr
ref android.R.styleable#Window_windowAllowReturnTransitionOverlap

public voidsetAttributes(WindowManager.LayoutParams a)
Specify custom window attributes. PLEASE NOTE: the layout params you give here should generally be from values previously retrieved with {@link #getAttributes()}; you probably do not want to blindly create and apply your own, since this will blow away any values set by the framework that you are not interested in.

param
a The new window attributes, which will completely override any current values.

        mWindowAttributes.copyFrom(a);
        dispatchWindowAttributesChanged(mWindowAttributes);
    
public abstract voidsetBackgroundDrawable(android.graphics.drawable.Drawable drawable)
Change the background of this window to a custom Drawable. Setting the background to null will make the window be opaque. To make the window transparent, you can use an empty drawable (for instance a ColorDrawable with the color 0 or the system drawable android:drawable/empty.)

param
drawable The new Drawable to use for this window's background.

public voidsetBackgroundDrawableResource(int resId)
Change the background of this window to a Drawable resource. Setting the background to null will make the window be opaque. To make the window transparent, you can use an empty drawable (for instance a ColorDrawable with the color 0 or the system drawable android:drawable/empty.)

param
resId The resource identifier of a drawable resource which will be installed as the new background.

        setBackgroundDrawable(mContext.getDrawable(resId));
    
public voidsetCallback(android.view.Window$Callback callback)
Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.

param
callback The desired Callback interface.

        mCallback = callback;
    
public abstract voidsetChildDrawable(int featureId, android.graphics.drawable.Drawable drawable)

public abstract voidsetChildInt(int featureId, int value)

public voidsetClipToOutline(boolean clipToOutline)
Sets whether window content should be clipped to the outline of the window background.

param
clipToOutline Whether window content should be clipped to the outline of the window background.
see
View#setClipToOutline(boolean)
see
android.R.styleable#Window_windowClipToOutline

public voidsetCloseOnTouchOutside(boolean close)

hide

        mCloseOnTouchOutside = close;
        mSetCloseOnTouchOutside = true;
    
public voidsetCloseOnTouchOutsideIfNotSet(boolean close)

hide

        if (!mSetCloseOnTouchOutside) {
            mCloseOnTouchOutside = close;
            mSetCloseOnTouchOutside = true;
        }
    
public voidsetContainer(android.view.Window container)
Set the container for this window. If not set, the DecorWindow operates as a top-level window; otherwise, it negotiates with the container to display itself appropriately.

param
container The desired containing Window.

        mContainer = container;
        if (container != null) {
            // Embedded screens never have a title.
            mFeatures |= 1<<FEATURE_NO_TITLE;
            mLocalFeatures |= 1<<FEATURE_NO_TITLE;
            container.mHasChildren = true;
        }
    
public abstract voidsetContentView(int layoutResID)
Convenience for {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} to set the screen content from a layout resource. The resource will be inflated, adding all top-level views to the screen.

param
layoutResID Resource ID to be inflated.
see
#setContentView(View, android.view.ViewGroup.LayoutParams)

public abstract voidsetContentView(View view)
Convenience for {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarhcy.

param
view The desired content to display.
see
#setContentView(View, android.view.ViewGroup.LayoutParams)

public abstract voidsetContentView(View view, ViewGroup.LayoutParams params)
Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.

Note that calling this function "locks in" various characteristics of the window that can not, from this point forward, be changed: the features that have been requested with {@link #requestFeature(int)}, and certain window flags as described in {@link #setFlags(int, int)}.

If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's TransitionManager will be used to animate content from the current content View to view.

param
view The desired content to display.
param
params Layout parameters for the view.
see
#getTransitionManager()
see
#setTransitionManager(android.transition.TransitionManager)

public voidsetDefaultIcon(int resId)
Set the default icon for this window. This will be overridden by any other icon set operation which could come from the theme or another explicit set.

hide

 
public voidsetDefaultLogo(int resId)
Set the default logo for this window. This will be overridden by any other logo set operation which could come from the theme or another explicit set.

hide

 
protected voidsetDefaultWindowFormat(int format)
Set the default format of window, as per the PixelFormat types. This is the format that will be used unless the client specifies in explicit format with setFormat();

param
format The new window format (see PixelFormat).
see
#setFormat
see
PixelFormat

        mDefaultWindowFormat = format;
        if (!mHaveWindowFormat) {
            final WindowManager.LayoutParams attrs = getAttributes();
            attrs.format = format;
            dispatchWindowAttributesChanged(attrs);
        }
    
public voidsetDimAmount(float amount)
Set the amount of dim behind the window when using {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides the default dim amount of that is selected by the Window based on its theme.

param
amount The new dim amount, from 0 for no dim to 1 for full dim.

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.dimAmount = amount;
        mHaveDimAmount = true;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetDisableWallpaperTouchEvents(boolean disable)

hide

        setPrivateFlags(disable
                ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
                WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
    
public voidsetElevation(float elevation)
Sets the window elevation.

Changes to this property take effect immediately and will cause the window surface to be recreated. This is an expensive operation and as a result, this property should not be animated.

param
elevation The window elevation.
see
View#setElevation(float)
see
android.R.styleable#Window_windowElevation

public voidsetEnterTransition(android.transition.Transition transition)
Sets the Transition that will be used to move Views into the initial scene. The entering Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as entering is governed by changing visibility from {@link View#INVISIBLE} to {@link View#VISIBLE}. If transition is null, entering Views will remain unaffected.

param
transition The Transition to use to move Views into the initial Scene.
attr
ref android.R.styleable#Window_windowEnterTransition

public voidsetExitTransition(android.transition.Transition transition)
Sets the Transition that will be used to move Views out of the scene when starting a new Activity. The exiting Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as exiting is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use to move Views out of the scene when calling a new Activity.
attr
ref android.R.styleable#Window_windowExitTransition

public abstract voidsetFeatureDrawable(int featureId, android.graphics.drawable.Drawable drawable)
Set an explicit Drawable value for feature of this window. You must have called requestFeature(featureId) before calling this function.

param
featureId The desired drawable feature to change. Features are constants defined by Window.
param
drawable A Drawable object to display.

public abstract voidsetFeatureDrawableAlpha(int featureId, int alpha)
Set a custom alpha value for the given drawable feature, controlling how much the background is visible through it.

param
featureId The desired drawable feature to change. Features are constants defined by Window.
param
alpha The alpha amount, 0 is completely transparent and 255 is completely opaque.

public abstract voidsetFeatureDrawableResource(int featureId, int resId)
Set the value for a drawable feature of this window, from a resource identifier. You must have called requestFeauture(featureId) before calling this function.

see
android.content.res.Resources#getDrawable(int)
param
featureId The desired drawable feature to change, defined as a constant by Window.
param
resId Resource identifier of the desired image.

public abstract voidsetFeatureDrawableUri(int featureId, android.net.Uri uri)
Set the value for a drawable feature of this window, from a URI. You must have called requestFeature(featureId) before calling this function.

The only URI currently supported is "content:", specifying an image in a content provider.

see
android.widget.ImageView#setImageURI
param
featureId The desired drawable feature to change. Features are constants defined by Window.
param
uri The desired URI.

public abstract voidsetFeatureInt(int featureId, int value)
Set the integer value for a feature. The range of the value depends on the feature being set. For {@link #FEATURE_PROGRESS}, it should go from 0 to 10000. At 10000 the progress is complete and the indicator hidden.

param
featureId The desired feature to change. Features are constants defined by Window.
param
value The value for the feature. The interpretation of this value is feature-specific.

public voidsetFlags(int flags, int mask)
Set the flags of the window, as per the {@link WindowManager.LayoutParams WindowManager.LayoutParams} flags.

Note that some flags must be set before the window decoration is created (by the first call to {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or {@link #getDecorView()}: {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These will be set for you based on the {@link android.R.attr#windowIsFloating} attribute.

param
flags The new window flags (see WindowManager.LayoutParams).
param
mask Which of the window flag bits to modify.
see
#addFlags
see
#clearFlags

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.flags = (attrs.flags&~mask) | (flags&mask);
        mForcedWindowFlags |= mask;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetFormat(int format)
Set the format of window, as per the PixelFormat types. This overrides the default format that is selected by the Window based on its window decorations.

param
format The new window format (see PixelFormat). Use PixelFormat.UNKNOWN to allow the Window to select the format.
see
PixelFormat

        final WindowManager.LayoutParams attrs = getAttributes();
        if (format != PixelFormat.UNKNOWN) {
            attrs.format = format;
            mHaveWindowFormat = true;
        } else {
            attrs.format = mDefaultWindowFormat;
            mHaveWindowFormat = false;
        }
        dispatchWindowAttributesChanged(attrs);
    
public voidsetGravity(int gravity)
Set the gravity of the window, as per the Gravity constants. This controls how the window manager is positioned in the overall window; it is only useful when using WRAP_CONTENT for the layout width or height.

param
gravity The desired gravity constant.
see
Gravity
see
#setLayout

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.gravity = gravity;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetIcon(int resId)
Set the primary icon for this window.

param
resId resource ID of a drawable to set

 
public voidsetLayout(int width, int height)
Set the width and height layout parameters of the window. The default for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT or an absolute value to make a window that is not full-screen.

param
width The desired layout width of the window.
param
height The desired layout height of the window.
see
ViewGroup.LayoutParams#height
see
ViewGroup.LayoutParams#width

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.width = width;
        attrs.height = height;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetLocalFocus(boolean hasFocus, boolean inTouchMode)
Set focus locally. The window should have the {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.

param
hasFocus Whether this window has focus or not.
param
inTouchMode Whether this window is in touch mode or not.

 
public voidsetLogo(int resId)
Set the logo for this window. A logo is often shown in place of an {@link #setIcon(int) icon} but is generally wider and communicates window title information as well.

param
resId resource ID of a drawable to set

 
public voidsetMediaController(android.media.session.MediaController controller)
Sets a {@link MediaController} to send media keys and volume changes to. If set, this should be preferred for all media keys and volume requests sent to this window.

param
controller The controller for the session which should receive media keys and volume changes.
see
android.app.Activity#setMediaController(android.media.session.MediaController)

    
public abstract voidsetNavigationBarColor(int color)
Sets the color of the navigation bar to {@param color}. For this to take effect, the window must be drawing the system bar backgrounds with {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set. If {@param color} is not opaque, consider setting {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.

The transitionName for the view background will be "android:navigation:background".

protected voidsetNeedsMenuKey(int value)
{@hide}

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.needsMenuKey = value;
        dispatchWindowAttributesChanged(attrs);
    
public final voidsetOnWindowDismissedCallback(android.view.Window$OnWindowDismissedCallback dcb)

hide

        mOnWindowDismissedCallback = dcb;
    
private voidsetPrivateFlags(int flags, int mask)

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
        dispatchWindowAttributesChanged(attrs);
    
public voidsetReenterTransition(android.transition.Transition transition)
Sets the Transition that will be used to move Views in to the scene when returning from a previously-started Activity. The entering Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as exiting is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will remain unaffected. If nothing is set, the default will be to use the same transition as {@link #setExitTransition(android.transition.Transition)}. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use to move Views into the scene when reentering from a previously-started Activity.
attr
ref android.R.styleable#Window_windowReenterTransition

public voidsetReturnTransition(android.transition.Transition transition)
Sets the Transition that will be used to move Views out of the scene when the Window is preparing to close, for example after a call to {@link android.app.Activity#finishAfterTransition()}. The exiting Views will be those that are regular Views or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend {@link android.transition.Visibility} as entering is governed by changing visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, entering Views will remain unaffected. If nothing is set, the default will be to use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.

param
transition The Transition to use to move Views out of the Scene when the Window is preparing to close.
attr
ref android.R.styleable#Window_windowReturnTransition

public voidsetSharedElementEnterTransition(android.transition.Transition transition)
Sets the Transition that will be used for shared elements transferred into the content Scene. Typical Transitions will affect size and location, such as {@link android.transition.ChangeBounds}. A null value will cause transferred shared elements to blink to the final position. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use for shared elements transferred into the content Scene.
attr
ref android.R.styleable#Window_windowSharedElementEnterTransition

public voidsetSharedElementExitTransition(android.transition.Transition transition)
Sets the Transition that will be used for shared elements after starting a new Activity before the shared elements are transferred to the called Activity. If the shared elements must animate during the exit transition, this Transition should be used. Upon completion, the shared elements may be transferred to the started Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window.
attr
ref android.R.styleable#Window_windowSharedElementExitTransition

public voidsetSharedElementReenterTransition(android.transition.Transition transition)
Sets the Transition that will be used for shared elements reentering from a started Activity after it has returned the shared element to it start location. If no value is set, this will default to {@link #setSharedElementExitTransition(android.transition.Transition)}. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use for shared elements in the launching Window after the shared element has returned to the Window.
attr
ref android.R.styleable#Window_windowSharedElementReenterTransition

public voidsetSharedElementReturnTransition(android.transition.Transition transition)
Sets the Transition that will be used for shared elements transferred back to a calling Activity. Typical Transitions will affect size and location, such as {@link android.transition.ChangeBounds}. A null value will cause transferred shared elements to blink to the final position. If no value is set, the default will be to use the same value as {@link #setSharedElementEnterTransition(android.transition.Transition)}. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.

param
transition The Transition to use for shared elements transferred out of the content Scene.
attr
ref android.R.styleable#Window_windowSharedElementReturnTransition

public voidsetSharedElementsUseOverlay(boolean sharedElementsUseOverlay)
Sets whether or not shared elements should use an Overlay during shared element transitions. The default value is true.

param
sharedElementsUseOverlay true indicates that shared elements should be transitioned with an Overlay or false to transition within the normal View hierarchy.
attr
ref android.R.styleable#Window_windowSharedElementsUseOverlay

 
public voidsetSoftInputMode(int mode)
Specify an explicit soft input mode to use for the window, as per {@link WindowManager.LayoutParams#softInputMode WindowManager.LayoutParams.softInputMode}. Providing anything besides "unspecified" here will override the input mode the window would normally retrieve from its theme.

        final WindowManager.LayoutParams attrs = getAttributes();
        if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
            attrs.softInputMode = mode;
            mHasSoftInputMode = true;
        } else {
            mHasSoftInputMode = false;
        }
        dispatchWindowAttributesChanged(attrs);
    
public abstract voidsetStatusBarColor(int color)
Sets the color of the status bar to {@param color}. For this to take effect, the window must be drawing the system bar backgrounds with {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set. If {@param color} is not opaque, consider setting {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.

The transitionName for the view background will be "android:status:background".

public abstract voidsetTitle(java.lang.CharSequence title)

public abstract voidsetTitleColor(int textColor)

public voidsetTransitionBackgroundFadeDuration(long fadeDurationMillis)
Sets the duration, in milliseconds, of the window background fade when transitioning into or away from an Activity when called with an Activity Transition.

When executing the enter transition, the background starts transparent and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is 300 milliseconds.

param
fadeDurationMillis The duration of the window background fade to or from opaque during enter transition.
see
#setEnterTransition(android.transition.Transition)
attr
ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration

 
public voidsetTransitionManager(android.transition.TransitionManager tm)
Set the {@link TransitionManager} to use for default transitions in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.

param
tm The TransitionManager to use for scene changes.
attr
ref android.R.styleable#Window_windowContentTransitionManager

        throw new UnsupportedOperationException();
    
public voidsetType(int type)
Set the type of the window, as per the WindowManager.LayoutParams types.

param
type The new window type (see WindowManager.LayoutParams).

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.type = type;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetUiOptions(int uiOptions, int mask)
Set extra options that will influence the UI for this window. Only the bits filtered by mask will be modified.

param
uiOptions Flags specifying extra options for this window.
param
mask Flags specifying which options should be modified. Others will remain unchanged.

 
public voidsetUiOptions(int uiOptions)
Set extra options that will influence the UI for this window.

param
uiOptions Flags specifying extra options for this window.

 
public abstract voidsetVolumeControlStream(int streamType)

see
android.app.Activity#setVolumeControlStream(int)

public voidsetWindowAnimations(int resId)
Specify custom animations to use for the window, as per {@link WindowManager.LayoutParams#windowAnimations WindowManager.LayoutParams.windowAnimations}. Providing anything besides 0 here will override the animations the window would normally retrieve from its theme.

        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.windowAnimations = resId;
        dispatchWindowAttributesChanged(attrs);
    
public voidsetWindowManager(WindowManager wm, android.os.IBinder appToken, java.lang.String appName, boolean hardwareAccelerated)
Set the window manager for use by this Window to, for example, display panels. This is not used for displaying the Window itself -- that must be done by the client.

param
wm The window manager for adding new windows.

        mAppToken = appToken;
        mAppName = appName;
        mHardwareAccelerated = hardwareAccelerated
                || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
        if (wm == null) {
            wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
        }
        mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
    
public voidsetWindowManager(WindowManager wm, android.os.IBinder appToken, java.lang.String appName)
Set the window manager for use by this Window to, for example, display panels. This is not used for displaying the Window itself -- that must be done by the client.

param
wm The window manager for adding new windows.

        setWindowManager(wm, appToken, appName, false);
    
public booleanshouldCloseOnTouch(android.content.Context context, MotionEvent event)

hide

        if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
                && isOutOfBounds(context, event) && peekDecorView() != null) {
            return true;
        }
        return false;
    
public abstract booleansuperDispatchGenericMotionEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the generic motion event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract booleansuperDispatchKeyEvent(KeyEvent event)
Used by custom windows, such as Dialog, to pass the key press event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract booleansuperDispatchKeyShortcutEvent(KeyEvent event)
Used by custom windows, such as Dialog, to pass the key shortcut press event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract booleansuperDispatchTouchEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the touch screen event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract booleansuperDispatchTrackballEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the trackball event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract voidtakeInputQueue(InputQueue.Callback callback)
Take ownership of this window's InputQueue. The window will no longer read and dispatch input events from the queue; it is your responsibility to do so.

public abstract voidtakeKeyEvents(boolean get)
Request that key events come to this activity. Use this if your activity has no views with focus, but the activity still wants a chance to process key events.

public abstract voidtakeSurface(SurfaceHolder.Callback2 callback)
Take ownership of this window's surface. The window's view hierarchy will no longer draw into the surface, though it will otherwise continue to operate (such as for receiving input events). The given SurfaceHolder callback will be used to tell you about state changes to the surface.

public abstract voidtogglePanel(int featureId, KeyEvent event)