Class sap.m.AppModule: sap/m/App

extends NavContainer

App is the root element of a UI5 mobile application. It inherits from NavContainer and thus provides its navigation capabilities. It also adds certain header tags to the HTML page which are considered useful for mobile apps.

Constructor Summary
new sap.m.App(sId?, mSettings?)Constructor for a new App.
Event Summary
orientationChange(oControlEvent)Fired when the orientation (portrait/landscape) of the device is changed.
Events borrowed from class sap.m.NavContainer
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.App.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.App with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.App.getMetadata()Returns a metadata object for class sap.m.App.
getBackgroundColor()Gets current value of property backgroundColor.
getBackgroundImage()Gets current value of property backgroundImage.
getBackgroundOpacity()Gets current value of property backgroundOpacity.
getBackgroundRepeat()Gets current value of property backgroundRepeat.
getHomeIcon()Gets current value of property homeIcon.
setBackgroundColor(sBackgroundColor)Sets a new value for property backgroundColor.
setBackgroundImage(sBackgroundImage)Sets a new value for property backgroundImage.
setBackgroundOpacity(fBackgroundOpacity)Sets a new value for property backgroundOpacity.
setBackgroundRepeat(bBackgroundRepeat)Sets a new value for property backgroundRepeat.
setHomeIcon(oHomeIcon)Sets a new value for property homeIcon.
attachOrientationChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the orientationChange event of this sap.m.App.
detachOrientationChange(fnFunction, oListener)Detaches event handler fnFunction from the orientationChange event of this sap.m.App.
fireOrientationChange(mArguments?)Fires event orientationChange to attached listeners.
Constructor Detail
new sap.m.App(sId?, mSettings?)
Constructor for a new App.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

In addition, all settings applicable to the base type sap.m.NavContainer can be used as well.

Parameters:
{string}sId? id for the new control, generated automatically if no id is given
{object}mSettings? initial settings for the new control
Event Detail
orientationChange(oControlEvent)
Fired when the orientation (portrait/landscape) of the device is changed.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{boolean}oControlEvent.getParameters.landscape Whether the device is in landscape orientation.
Deprecated:
Since version 1.20.0. use sap.ui.Device.orientation.attachHandler(...)
Method Detail
sap.m.App.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.App with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.m.NavContainer.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.App.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.App.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getBackgroundColor(): string
Gets current value of property backgroundColor.

Background color of the App. If set, this color will override the default background defined by the theme. So this should only be set when really required. Any configured background image will be placed above this colored background. But any theme adaptation in the Theme Designer will override this setting. Use the "backgroundRepeat" property to define whether this image should be stretched to cover the complete App or whether it should be tiled.

Since:
1.11.2
Returns:
{string} Value of property backgroundColor
getBackgroundImage(): sap.ui.core.URI
Gets current value of property backgroundImage.

Background image of the App. If set, this image will override the default background defined by the theme. So this should only be set when really required. This background image will be placed above any color set for the background. But any theme adaptation in the Theme Designer will override this image setting. Use the "backgroundRepeat" property to define whether this image should be stretched to cover the complete App or whether it should be tiled.

Since:
1.11.2
Returns:
{sap.ui.core.URI} Value of property backgroundImage
getBackgroundOpacity(): float
Gets current value of property backgroundOpacity.

Opacity of the background image. The opacity can be set between 0 (fully transparent) and 1 fully opaque). This can be used to make the application content better readable by making the background image partly transparent.

Default value is 1.

Since:
1.11.2
Returns:
{float} Value of property backgroundOpacity
getBackgroundRepeat(): boolean
Gets current value of property backgroundRepeat.

Whether the background image (if configured) should be proportionally stretched to cover the whole App (false) or whether it should be tiled (true).

Default value is false.

Since:
1.11.2
Returns:
{boolean} Value of property backgroundRepeat
getHomeIcon(): any
Gets current value of property homeIcon.

The icon to be displayed on the home screen of iOS devices after the user does "add to home screen".

Note that only the first attempt to set the homeIcon will be executed, subsequent settings are ignored.

This icon must be in PNG format. The property can either hold the URL of one single icon which is used for all devices (and possibly scaled, which looks not perfect), or an object holding icon URLs for the different required sizes.

A desktop icon (used for bookmarks and overriding the favicon) can also be configured. This requires an object to be given and the "icon" property of this object then defines the desktop bookmark icon. For this icon, PNG is not supported by Internet Explorer. The ICO format is supported by all browsers. ICO is also preferred for this desktop icon setting because the file can contain different images for different resolutions.

One example is:

app.setHomeIcon({ 'phone':'phone-icon.png', 'phone@2':'phone-retina.png', 'tablet':'tablet-icon.png', 'tablet@2':'tablet-retina.png', 'icon':'desktop.ico' });

The respective image sizes are 57/114 px for the phone and 72/144 px for the tablet. If an object is given but one of the sizes is not given, the largest given icon will be used for this size.

On Android these icons may or may not be used by the device. Apparently chances can be improved by adding glare effect and rounded corners, setting the file name so it ends with "-precomposed.png" and setting the "homeIconPrecomposed" property to "true".

Returns:
{any} Value of property homeIcon
setBackgroundColor(sBackgroundColor): sap.m.App
Sets a new value for property backgroundColor.

Background color of the App. If set, this color will override the default background defined by the theme. So this should only be set when really required. Any configured background image will be placed above this colored background. But any theme adaptation in the Theme Designer will override this setting. Use the "backgroundRepeat" property to define whether this image should be stretched to cover the complete App or whether it should be tiled.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sBackgroundColor New value for property backgroundColor
Since:
1.11.2
Returns:
{sap.m.App} Reference to this in order to allow method chaining
setBackgroundImage(sBackgroundImage): sap.m.App
Sets a new value for property backgroundImage.

Background image of the App. If set, this image will override the default background defined by the theme. So this should only be set when really required. This background image will be placed above any color set for the background. But any theme adaptation in the Theme Designer will override this image setting. Use the "backgroundRepeat" property to define whether this image should be stretched to cover the complete App or whether it should be tiled.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{sap.ui.core.URI}sBackgroundImage New value for property backgroundImage
Since:
1.11.2
Returns:
{sap.m.App} Reference to this in order to allow method chaining
setBackgroundOpacity(fBackgroundOpacity): sap.m.App
Sets a new value for property backgroundOpacity.

Opacity of the background image. The opacity can be set between 0 (fully transparent) and 1 fully opaque). This can be used to make the application content better readable by making the background image partly transparent.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is 1.

Parameters:
{float}fBackgroundOpacity New value for property backgroundOpacity
Since:
1.11.2
Returns:
{sap.m.App} Reference to this in order to allow method chaining
setBackgroundRepeat(bBackgroundRepeat): sap.m.App
Sets a new value for property backgroundRepeat.

Whether the background image (if configured) should be proportionally stretched to cover the whole App (false) or whether it should be tiled (true).

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Parameters:
{boolean}bBackgroundRepeat New value for property backgroundRepeat
Since:
1.11.2
Returns:
{sap.m.App} Reference to this in order to allow method chaining
setHomeIcon(oHomeIcon): sap.m.App
Sets a new value for property homeIcon.

The icon to be displayed on the home screen of iOS devices after the user does "add to home screen".

Note that only the first attempt to set the homeIcon will be executed, subsequent settings are ignored.

This icon must be in PNG format. The property can either hold the URL of one single icon which is used for all devices (and possibly scaled, which looks not perfect), or an object holding icon URLs for the different required sizes.

A desktop icon (used for bookmarks and overriding the favicon) can also be configured. This requires an object to be given and the "icon" property of this object then defines the desktop bookmark icon. For this icon, PNG is not supported by Internet Explorer. The ICO format is supported by all browsers. ICO is also preferred for this desktop icon setting because the file can contain different images for different resolutions.

One example is:

app.setHomeIcon({ 'phone':'phone-icon.png', 'phone@2':'phone-retina.png', 'tablet':'tablet-icon.png', 'tablet@2':'tablet-retina.png', 'icon':'desktop.ico' });

The respective image sizes are 57/114 px for the phone and 72/144 px for the tablet. If an object is given but one of the sizes is not given, the largest given icon will be used for this size.

On Android these icons may or may not be used by the device. Apparently chances can be improved by adding glare effect and rounded corners, setting the file name so it ends with "-precomposed.png" and setting the "homeIconPrecomposed" property to "true".

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{any}oHomeIcon New value for property homeIcon
Returns:
{sap.m.App} Reference to this in order to allow method chaining
attachOrientationChange(oData?, fnFunction, oListener?): sap.m.App
Attaches event handler fnFunction to the orientationChange event of this sap.m.App.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.App itself.

Fired when the orientation (portrait/landscape) of the device is changed.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.App itself
Deprecated:
Since version 1.20.0. use sap.ui.Device.orientation.attachHandler(...)
Returns:
{sap.m.App} Reference to this in order to allow method chaining
detachOrientationChange(fnFunction, oListener): sap.m.App
Detaches event handler fnFunction from the orientationChange event of this sap.m.App.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Deprecated:
Since version 1.20.0. use sap.ui.Device.orientation.attachHandler(...)
Returns:
{sap.m.App} Reference to this in order to allow method chaining
fireOrientationChange(mArguments?): sap.m.App
Fires event orientationChange to attached listeners.

Expects the following event parameters:

  • landscape of type booleanWhether the device is in landscape orientation.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Deprecated:
Since version 1.20.0. use sap.ui.Device.orientation.attachHandler(...)
Returns:
{sap.m.App} Reference to this in order to allow method chaining