This release (2.3.62+) ships the preliminary support for mobile devices, a new WebSharper component we call WebSharper Mobile (WM). (Be sure to update your extensions to their matching versions from the Extensions page.) WM consists of the following:
The WM layer is designed in two parts: a general API meant to convey core mobile functionality such as supplying accelerometer and GPS data or accessing the camera capabilities, and various platform-specific APIs. In this first iteration, only the core API is shipped. Subsequent releases will include an increasing number of platform-specific capabilities for each major platform, such as Bluetooth communication, calling API, etc.
A jQuery Mobile formlet application running on Android is depicted on the figure to the left. You can follow through building this application in this InfoQ article.
If you are planning to use WebSharper Mobile for Android development, you will need the following in place:
C:\Program Files\Java\jdk1.6.0_27\bin
, C:\android-sdk\tools
and C:\android-sdk\platform-tools
to the system path. You also have to set either the environment variable ANDROID_HOME
or ANDROID_SDK
to the equivalent of C:\android-sdk\tools
.The sequence of steps closely follows those normally done, with a couple minor additions:
.keystore
file (read below) to the project’s folder (that is, the mobile project itself, where your mobile.config
is).mobile.config
, uncomment one of the build elements (there are two sample elements that you can use). Change the name of the output and the SDK version. Note: for this release of WebSharper mobile, you can only build for SDK 7, and it will work on both the 2.x and 3.x series. Note: the SDK version is sometimes also referred to as Android API level..keystore
(read below).bin\html
, run adb install –r .apk
. Note: this will fail if the version of the device is lower than the version you specified, or if there are several emulators running.adb install ...
will fail and say the device is offline. This can be solved by running adb kill-server
and then installing again.You can use the following to "hardcode" a given GPS coordinate into your Android emulator as your current position.
Enable the telnet client (skip if you are using Windows XP):
Find out which port your emulator is using by looking at the window’s title. For example, your emulator might be on port 5556, so the title is 5556:.
Run (command line) telnet localhost
.
After the application has started (geolocation works on listeners, so it must be after the application registered its listener) enter: geo fix
. Notice the order of arguments. The command might fail, just retype it.
.keystore
filesYou can create one using a tool called keytool. You can just run it, if you correctly set up your system path in an earlier step.
keytool -genkey -v -keystore .keystore -alias -keyalg RSA -validity 10000
to generate a new one.You will need the following:
When starting a new WebSharper Visual Studio project you might wonder what the offline vs online application templates are. As mentioned earlier, online applications have a server-side, offline ones don't. For instance, a simple static HTML application can be modeled as an offline sitelet project. For online mobile applications, the following apply:
mobile.config
file. (The online projects have a mobile.config with a sample server location, this needs to be overridden).Can’t find what you were looking for? Drop us a line.
20221229 · 30 min read
20211230 · 20 min read