Building Mobile Enterprise Applications : Using webMethods Mobile Designer : Defining Resources for a Mobile Application Project : Accessing Resources in Your Application Code
Accessing Resources in Your Application Code
To access resources in your application code, Mobile Designer provides the following run-time classes:
*com.softwareag.mobile.runtime.media.AudioHandler
Use in your application code to access and manage the audio resources. The AudioHandler class includes the loadSound and unloadSound methods that you can use to load and unload audio resources.
*com.softwareag.mobile.runtime.media.ImageBase and com.softwareag.mobile.runtime.media.ImageHandler
Use in your application code to access and manage image resources. The ImageBase class includes the getImage, loadImageID, and unloadImageID methods that you can use to load and unload image resources.
*com.softwareag.mobile.runtime.media.TextHandler
Use in your application code to access and manage text line resources. The TextHandler class includes the getString method to get a text string.
*com.softwareag.mobile.runtime.storage.ResourceHandler
If you use resource blocks and packs, use this class in your application code to manage the blocks and packs. The ResouceHandler class includes the loadResourceBlock and unloadResourceBlock methods that you can use to load and unload resource blocks.
When using a method to load or unload a resource, you specify the resource’s identifier. When Mobile Designer runs your resource handler, it sets parameters for the resources in the com.softwareag.mobile.runtime.Parameters class. For example, if you want to load an audio resource with the identifier RESID_STARTUP, you can use the following method call:
AudioHandler.loadSound (Parameters.RESID_STARTUP);
If your resource handler bundles resources into resource blocks and packs, in your application code, you must load the resource bundle containing a resource before you load the specific resource. Continuing with the previous example, suppose the RESID_STARTUP audio resource is included in the resource block with the identifier RESBLOCKID_AUDIO, you can use the following method calls:
ResourceHandler loadResourceBlock (Parameters.RESBLOCKID_AUDIO);
AudioHandler.loadSound (Parameters.RESID_STARTUP);
When the application is no longer using the resources in a block, it can use the unloadResourceBlock, which is also in the ResourceHandler class to unload the resource block.
Note:  
If you are using resource blocks and packs, your application code does not need to load and unload resource packs. Mobile Designer keeps track of the packs required for each resource block. When you load a resource block, Mobile Designer takes care of loading the appropriate pack that contains the resource block.
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback