Android Delphi Projects Mobile News REST

Hello Google Glass from Delphi XE5

Google’s new Glass platform is a very revolutionary Android device, but the question I really wanted to know is if I could develop for it with Delphi XE5. Turns out the answer is Yes.

There are actually two different options for developing Glassware: Mirror API and GDK.

The first is the Google Mirror API, which allows you to build services, called Glassware, that interact with Google Glass. It provides this functionality over a cloud-based API and does not require running code on Glass. This is accomplished through a REST and JSON based API. Thanks to the new TRESTClient components in Delphi XE5 this should be easy enough to do.

The GDK on the other hand is the avenue where you build an actual APK that runs on the Google Glass device itself. This gives you the most access to the device, its sensors and features. Turns out this is also easy enough to do with Delphi XE5.

The actual GDK builds on top of the Android SDK. You can develop apps to run on Glass with either the Android SDK or GDK, but the GDK is necessary to take advantage of some of the Glass specific features.

If you run SysCheck on Glass (which takes some effort) you discover it has an ARMv7 PRocessor rev 3 (v71) with Android OS Version 4.0.4 and NEON support. Those meet the main requirements for Delphi XE5 development. So I created a simple Hello World app and ran it.

This first screenshot shows Glass appearing in the Project Manager as a valid target (once the required USB drivers were installed, which was tricky for glass).


Here is a screenshot of the app running on Glass

Delphi XE5 App running on Google Glass

I didn’t hide the status bar, which most Glassware does, and it does nothing other than serve the purpose of showing a Delphi XE5 app running on Google Glass. There were no special settings (other than the dark theme, which is a matter of taste) to make the app run on Glass. It just works.

And lastly a quick selfie of me and Glass, taken through glass.


I was hoping it would look more red than orange, but should have known Tangerine would be orange.

Rest assured, there will be more coverage of Delphi and Glass. We are just getting warmed up. This app was not using the GDK (which is still in Beta) but it is an actual Delphi app running on Glass. What an exciting day!


Wireless Android Debugging with Delphi xE5

Previously I blogged about how to connect to an emulator on a remote (or the host) machine. That also works for hardware connected to remote machines. But sometimes you want to work with hardware that isn’t even connected at all. Not to worry, here is how to wirelessly connect and debug with your favorite development tool. One note though, WiFi slower than a USB connection, so you will see a little delay sometimes.


  • A machine (Mac or PC) you can connect the Android device to that has ADB (Android Debug Bridge) installed. This is part of the Android SDK. As well as necessary ADB USB Drivers (required on Windows). This can be your development machine, or another machine.
  • A non-segmented wireless network that both your development machine and Android device are connected. (Segmenting prevents two connected devices from connecting to each other).

These commands work with ADB (Android Debug Bridge). It is easiest if you add it to your path. By default it is found in the following location, but you can install it anywhere on your system (Select the “Use An Existing IDE” option when downloading).

C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\platform-tools

First you need to connect your Android device to any computer. With USB debugging turned on, verify you have access to the device via ADB with the following command:


adb devices


List of devices attached 
8605fa72        device

If the list is empty, then you need to enable USB debugging and make sure you have the USB ADB Bridge driver for your device installed.

Once ADB is setup, you can get the IP address with the following command:

adb shell netcfg|grep wlan0

Which should give you output like:

wlan0  UP  0x00001043 2a:32:11:42:aa:3c

Then put the device in TCPIP mode with the command:

adb kill-server
adb tcpip 5555

Then on your machine that is running Delphi XE5 go to the command window and type (with the IP address from above):

adb connect

Then you can verify it worked from that same command prompt


adb devices


List of devices attached   device

And now you can connect to that device wirelessly from Delphi. Like I mentioned before, this is slower, so expect some delays on deploy and responding to breakpoints.

There is some more information on Stack Overflow, including some different options if you have a rooted Android device.

Android Conferences iOS Mobile

Sending a URL to Another App on Android and iOS with Delphi XE5

Here is the source code for my Open and View URL library from my CodeRage 8 session “Beyond the App”. Here is a download of the example app. I’ll see about posting it to a SVN repository too so it can grow and evolve. Thanks to Al Mannarino for his code that started this!

Note the code is using TidURL.URLEncode on all URLs. I found it is only required on the maps for iOS (iOS doesn’t like spaces) but may be causing trouble with the geo:// on Android.

Some example protocols

  • http, tel, sms, fb, mailto, twitter, geo, etc.

Example URLs

  • – Common to both iOS & Android –
  • tel://(415)834-3131
  • sms://1234
  • (This opens with the Twitter client on Android)
  • mailto://
  • twitter://user?screen_name=coderage
  • fb://profile/34960937498 (get the UID from or for whatever page you are looking for)
  • – iOS Specific –
  • Scotts Valley Drive, Scotts Valley, CA 95066 (this needs the URL encode – Apple has some additional APIs that are recommended.)
  • – Android Only –
  • content://contacts/people/
  • content://contacts/people/1
  • geo://0,0?q=5617 Scotts Valley Drive, Scotts Valley, CA 95066
  • geo://46.191200, -122.194400 (I think this one doesn’t like the URLEncode)
unit OpenViewUrl;


// URLEncode is performed on the URL
// so you need to format it   protocol://path
function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;


  IdURI, SysUtils, Classes, FMX.Dialogs,
  FMX.Helpers.Android, Androidapi.JNI.GraphicsContentViewText,
  Androidapi.JNI.Net, Androidapi.JNI.JavaTypes;
  Macapi.Helpers, iOSapi.Foundation, FMX.Helpers.iOS;

function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;
  Intent: JIntent;
// There may be an issue with the geo: prefix and URLEncode.
// will need to research
  Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW,
    on e: Exception do
      if DisplayError then ShowMessage('Error: ' + e.Message);
  NSU: NSUrl;
  // iOS doesn't like spaces, so URL encode is important.
  NSU := StrToNSUrl(TIdURI.URLEncode(URL));
  if SharedApplication.canOpenURL(NSU) then
    if DisplayError then
      ShowMessage('Error: Opening "' + URL + '" not supported.');
  raise Exception.Create('Not supported!');

Android iOS Mobile

Reading Barcodes with XE5 – Preliminary post

Fernando Rizotto has an example of using XE4 on iOS to read a barcode. He is using an iOS specific library. Another library that is available on both iOS and Android is OpenCV. It is a full open source computer vision library with a lot of great features, one of which is reading barcodes.


Fun with external Java libraries on XE5 by Paul Foster

Paul Foster shared his experiences working with External Java libraries on Android with XE5 on Google+. Here is a PDF he put together for you to download.


Delphi XE5 Android “Uses Permissions”

The permissions required by a Delphi XE5 Android application are defined through the Uses Permissions dialog. It is found under Project -> Options… [Shift+Ctrl+F11].


RAD Studio XE5 Android "Uses Permissions" Dialog

If you select other Targets besides Android then the list is blank, for now. By default the following common permissions are selected. If you do not select a permission then any calls you make that require that permission will fail. The “Internet” permission is required for any network access, even your local network.

If you scroll down the list you will see an Advanced node which contains permissions that are less commonly used permissions. For many apps you will never need to change these permissions, but your users may notice the “services that can cost money” warning next to Call phone and Internet permission request, so you may want to remove those.

The requested permissions are automatically added to the AndroidManifest.xml file, which is read by the Android operating system and Google Play store to know which permissions your app requested.

Android iOS Mobile

Blackberry is Still Ahead of Microsoft

When talking about Delphi XE5’s support for Android and iOS, someone usually asks if we plan to support Windows Phone, but never asks (that I’ve heard) if we plan to support Blackberry. In the news we keep hearing how Blackberry is struggling and losing market share, while Microsoft is fighting to gain market share. Interestingly Blackberry is still ahead of Microsoft.

Mobile Market Share


Looking at ComScore’s latest numbers we see Blackberry has 4.3% while Microsoft has 3.0%. Both are still in decline over the long haul. So even if Microsoft captured Blackberry’s 4.3% and Symbian’s 0.3% they would still only be at 7.6% compared to Android’s 51.8% and Apple’s 40.4%.

Microsoft has a way to go before they become a serious contender, and any other smartphone OS will be fighting an uphill battle to gain a foothold. With Microsoft’s deep pockets they could ride out a much longer storm than any upstart in this space, so I expect they are the only one who could turn up as an actual 3rd alternative.

Components iOS Mobile

TMS Pack for FireMonkey now supports XE5 and Android

TMS Pack for FireMonkeyVery exciting to see an update from TMS for their TMS Pack for FireMonkey with support for XE5 and Android (as well as iOS, OS X and Windows). Their pack includes a great diverse collection of controls for both mobile and desktop apps.

Android Mobile

Android Fragmentation

Fragmentation is the term used to describe all the variations available on the Android platform. Android has many manufacturers and models, unlike iOS where there is only one manufacturer, and they only have 3 (or 4) different models: iPhone, iPod, iPad (and iPad Mini).

The Android Dashboard is a great resource for tracking the adoption of different versions of the Android OS. It is updated monthly and also covers screen sizes and densities and Open GL versions.

Android version pie chart

Another great resource is OpenSignal fragmentation report. It shows market share by model and manufacturer, as well as some different ways of looking at the information in the Android Dashboard, as well as screen size. It appears to be updated annually.

Android Brand Fragmentation

I didn’t realize Samsung had almost 50% of the Android market, and I expected HTC to have a larger share. No wonder Apple feels threatened by Samsung. Noticeably missing from their list is any Amazon Kindles or Barns and Noble Nooks. That could be because they do not access the Google Play Store by default. I didn’t see the method of data collection.

Fragmentation is a bit of a headache for the app developer because there are so many different variations to take into consideration. The flip side though, is the flexibility of Android has really lead to its mass adoption. It works in both the ultra high-end luxury devices as well as the low-end economy devices. So while it is difficult to get an app that works on all devices, you still have a lot of possibilities to choose from.

Android Mobile

SysCheck for XE5 Compatibility

Screen Shot 2013-09-21 at 12.10.53 AMWant to know if your Android device is compatible with XE5? Well you can check out the compatibility lists, or download SysCheck by Christopher Moeller.

When you run it the first line tells you if you have an ARMv7, second line is Android OS version, and 3rd line is if you have NEON instruction support. Those are the dependencies of Delphi XE5 on Android. The rest of the lines are extra details for your information.

When you run it your output should look something like the following. If  those three lines check out then your device is ready for Delphi XE5 development.