Running Flex apps on iPhone/iPad and Android

11th October 2011

The ArcGIS web APIs are a powerful way to create mapping applications using JavaScript, Flex or Silverlight. However, many mobile devices do not support Flex or Silverlight, and JavaScript apps have drawbacks: they don’t always behave the same way across different browsers, they do not work well without an active network connection, and they generally have less functionality than Flex or Silverlight apps (simpler UI, inability to access as much hardware, etc).

Of course, mobile technologies evolve rapidly, and it’s likely that these criticisms of JavaScript will seem outdated and unfair before very long. Still, we were excited earlier this year when Adobe released Flash Builder 4.5, a development tool that allows cross-platform Flex apps, including GIS apps built with Esri’s ArcGIS API for Flex, to be deployed to iOS devices (iPhone, iPad, iPod Touch), Android devices (phones and tablets), and the BlackBerry PlayBook tablet.

On Android and BlackBerry PlayBook, Flex mobile apps run on AIR, a runtime developed by Adobe. AIR is pre-installed on PlayBook, and can be downloaded for free on Android. Since iOS apps distributed through the Apple App Store are not permitted to execute on third-party runtimes, Flex apps for iOS are normally compiled to native ARM assembly so they can be executed directly on the CPU.

The ArcGIS API for Flex 2.4 includes two mobile Flex samples to help developers get started. Since the API is now capable of recognising multi-touch gestures, Flex is a viable way to develop cross-platform mobile GIS apps. Quite a few of the Flex API code samples originally designed for the web can also be compiled without modification and run on mobile devices. For example, the following screenshot shows the Switching Basemaps web sample running on an iPhone 4. However, although the app may work without modification, sometimes the UI should be redesigned to take into account a smaller screen or lack of a physical keyboard.

AIR can access the GPS, accelerometer, microphone and camera on most mobile devices, although not the gyroscope or compass, so if you need these then you will have to use native code (i.e. Objective-C for iOS, Java for Android). The new AIR 3 runtime has support for Native Extensions, which allows native code modules to be linked with Flex apps.

Free ArcGIS apps written using Flex include MuniTracker, a public transport information app for San Francisco, and ArcGIS Viewer, a lightweight GIS viewer modelled on the ArcGIS Viewer for Flex, although it uses a different codebase because iOS devices do not support apps with a modular architecture like the Flex Viewer. You can download these apps through the App Store/Android Market. Flex apps seem to run quite well on mobile platforms, but runtime performance and battery use need to be considered. For example, MuniTracker disables animated transitions when a user zooms in and out on the map in order to conserve resources, although this behaviour may look a bit odd to users who are accustomed to seeing smooth zoom-level transitions.

More information about designing, building and deploying Flex mobile apps can be found in this guide: Developing Mobile Applications with Adobe Flex and Adobe Flash Builder.