getApplicationContext()
Retrieves the application context information.
Signature
public Canvas.ApplicationContext getApplicationContext()
Return Value
Usage
Use this method to get the application context information for your canvas app.
Example
The following example implementation of the CanvasLifecycleHandler onRender() method uses the provided RenderContext to retrieve the application context information and then checks the namespace, version, and app URL.
1public void onRender(Canvas.RenderContext renderContext){
2 Canvas.ApplicationContext app = renderContext.getApplicationContext();
3 if (!'MyNamespace'.equals(app.getNamespace())){
4 // This application is installed, add code as needed
5 ...
6 }
7
8 // Check the application version
9 Double currentVersion = Double.valueOf(app.getVersion());
10
11 if (currentVersion <= 5){
12 // Add version specific code as needed
13 ...
14 // Tell the canvas application to operate in deprecated mode
15 app.setCanvasUrlPath('/canvas?deprecated=true');
16 }
17}