Designer 10.5 | webMethods Mobile Development | Code Snippets | Detecting the Current Platform
 
Detecting the Current Platform
At run time, it is often required to get information on the platform on which the application is running. This information may be used, for example, to return a color value that depends on the current platform.
The com.softwareag.mobile.runtime.toolkit.AbstractApplicationController contains public methods for determining the current platform:
boolean runningOnAndroid();
boolean runningOnIOS();
These methods can also be used if you want to simulate your application using Phoney. The return value then depends on the activated handset.
See the following snippet for an example:
import com.softwareag.mobile.runtime.toolkit.AbstractApplicationController;

public int getColorValue() {
int colorValue = 0xff000000;
if(AbstractApplicationController.getInstance().runningOnAndroid()) {
colorValue = 0xff00ff00;
}
return colorValue;
}
Related Topics