Categories
Android

Manually Installing Android SDK, NDK, and Java for FireMonkey Development

10.3 Rio’s installer (I use and recommend the EXE/web over the ISO, since it is faster and more flexible) does a fantastic job of installing and setting everything up for Android development, without requiring any manual steps. Still, sometimes it is nice to be able to manually install everything, which brings me to this guide.

I’m a big believer in understanding the way the underlying systems work, and installing this way is more work, but you are able to see how everything works together. Also, this allows you to share SDKs between multiple installations, and also place the tools like ADB on your path for easy use. Not to say you can’t do all of that with the automatic install, but sometimes it is nice to get your hands dirty.

I also occasionally run into people who are having trouble getting things installed for various reasons. So this is a great way to troubleshoot installation issues.

This assumes you already have RAD Studio, Delphi, or C++Builder 10.3 Rio already installed. 10.3 Rio changed the versions of the SDK and NDK that it uses, so this guide won’t work with other versions. Also, I switched to AdoptOpenJDK instead of the traditional Oracle JDK. I’ll show you how to install that here, but if you use a different JDK that will be different for you.

What is the OpenJDK?

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License version 2 with a linking exception. It is the official reference implementation of Java SE since version 7.

There are multiple builds available, with different terms and support options. Why not just use the Java SE JDK? Oracle has changed the license on it that may require you to purchase a license to use it. For my purposes it is better save than sorry, plus the OpenJDK is a lot smaller and less annoying. I picked AdoptOpenJDK, which seems to be the most popular option, but this should mostly work the same with any build.

AdoptOpenJDK includes the JRE (Java Runtime Environment) too, so just one install. You must install it first because you can’t run the Android SDK manager without Java installed, and the IDE users the JDK for KeyTool and JarSigner.

AdoptOpenJDK Install Instructions

Download the Windows installer for OpenJDK 8 (LTS). I used the 64-bit Windows version with the HotSpot JVM, and then just run the installation. Be sure to tell it to set the JAVA_HOME environment variable.

While installing AdoptOpenJDK, have it Set JAVA_HOME environment variable.

Installing the Android SDK

When you visit the site to download the Android SDK they try to get you to download the full Android Studio, but you don’t need all of that. If you scroll to the bottom, you will see the “Command line tools only” downloads. One note, the downloads listed on the site no longer include the GUI SDK Manager. If you scroll down further, I’ll show you how you can download that and use it instead.

Command-Line Only install

  • sdk-tools-windows-4333796.zip
  • Windows Platform SDK
  • 148 MB (156,136,858 bytes)
  • SHA256 7e81d69c303e47a4f0e748a6352d85cd0c8fd90a5a95ae4e076b5e5f960d3c7a

This isn’t an installer, so just pick a folder to unzip it into. You will just find a “tools” folder in the zip. This contains the SDK Manager to install the rest of the Android SDK. I typically unzip it into the folder:

C:\Users\Public\Documents\Embarcadero\Studio\AndroidSDK\

Then use the sdkmanager command-line tool (in the tools\bin folder) to install everything you need. Notice I am installing the Android 26 Platform. This is the version you want to use with 10.3 Rio. It meets the new Target SDK requirements and still gives your Android apps maximum compatibility. This is the version 10.3 Rio is designed to work with.

sdkmanager "build-tools;29.0.0" "extras;google;usb_driver" "platforms;android-26" "tools" "platform-tools" 

Android SDK with GUI Install

For some reason the Android SDK GUI Installer isn’t listed for download, but the file is still available on their servers.

The fact we are installing an older version of the SDK isn’t a big deal because we will still update it when we are done, but now we have a choice of using the command-line interface like I showed in the previous section, or using the GUI SDK Manager by running the Android.bat file in the tools folder.

Once you run the SDK manager, you want to install the latest Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, Android API 26 SDK Platform, and the Google USB Driver. It will default to installing a lot of other things you don’t need. Feel free to deselect those. The Google USB Driver isn’t technically needed, but is nice to have.

The GUI for the Android SDK Manager

Once you’ve selected what you want installed, you can always update them via the command line with the sdkmanager utility in the tools\bin folder

sdkmanager --update

Installing the Android NDK

10.3 Rio updated the version of the Android NDK it uses to release 17b. It was the latest at the time of Rio’s development. There have been some new NDK releases since then. If you visit the Older Releases page for the Android NDK you will see 17b isn’t listed there, but the download file is still available. 17c may work, but I haven’t tested it extensively yet.

The NDK is also a zip file, so just extract it to the folder of your choosing. I’ll extract it next to my Android SDK. The root folder in the zip file is “android-ndk-r17b”

C:\Users\Public\Documents\Embarcadero\Studio\android-ndk-r17b 

There are no further installation steps necessary. Your folders should look something like this when you are done:

The folder containing the Android SDK and NDK

I’ve expanded the directories so you can see the build tools and Android platforms also installed

Environment Variables and System Path

Last thing you need to do is set up some Environment Variables and add things to your system path. This isn’t strictly necessary, but I highly recommend it!

Make sure your JAVA_HOME is correct, and set the ANDROID_HOME environment variable.

Then add the following to your system path

  • %JAVA_HOME%\bin (you can replace the expanded version with this)
  • %JAVA_HOME%\jre\bin
  • %ANDROID_HOME%\tools
  • %ANDROID_HOME%\tools\bin
  • %ANDROID_HOME%\platform-tools
The first JAVA path is the JRE, the second is the JDK.
Using the environment variables in the path saves environment space.

Settings Up the IDE SDK Manager

Since we’ve installed the SDK manually, we need to tell the IDE where to find it. This is really simple. Go into Tools ? Options ? Deployment ? SDK Manager (or just use the IDE search for SDK Manager) and add a new SDK entry.

If you have an existing Android entry here, you can remove it before adding a new one.
We are adding a new Android platform.
Provide the three paths based on where you installed them

The next stage in the wizard looks to make sure it can find everything it needs. If you didn’t install everything with the Android SDK Manager, then you may see a warning symbol next to something. If that is the case go back and double check the installation.

Be sure you select Android-26 for the API level, especially if you installed other versions too.
The SDK Manager found everything it needs to continue.

And with that you are ready to develop and deploy Android apps with FireMonkey.

Categories
Android devices News Source Code

WebBroker on Android and Raspberry Pi 3

I covered this previously in a few webinars and presentations, but never published the source code for WebBroker on Android. To be honest I hadn’t tested it with C++Builder before, but I completely expected it to work, and it did. I also updated the tests on Emteria.OS (FKA RTAndroid) and it also works there.

The process of porting a Delphi or C++Builder WebBroker project to Android is pretty straight forward, but I’m publishing the code anyway. You create a Windows FMX WebBroker project, then copy all the code into a regular FireMonkey project. You will need to copy a few files from the RTL folder locally so you can reference them since they aren’t included in the Android package.

  • Web.WebReq.pas
  • Web.WebBroker.pas
  • Web.WebConst.pas
  • IdHTTPWebBrokerBridge.pas
  • IdCompilerDefines.inc
  • For C++Builder you also need
    • Web.WebReq.hpp
    • Web.WebBroker.hpp
    • Web.WebConst.hpp
    • IdHTTPWebBrokerBridge.hpp

Here are the links for the Delphi and C++Builder projects. They were built and tested in with 10.3.1 Rio. I also compiled some updated details on how to build the project and how to install and test on Emteria.OS.

I mention this in the slide deck, but officially WebBroker isn’t supported on Android. I tested it, and it seems to work, but if you run into an instance where it doesn’t work as expected, then you are on your own. Please don’t contact support and tell them I said it should work. Thanks!

Previous webinars:

Delphi and C++Builder on Raspberry Pi and SBC

Slides

Revisiting Raspberry Pi, Android and the SBC

Slides

See also: Targeting Chrome OS with Delphi via Android and Linux

Categories
10.3 Rio Android News webinar

Get the Most out of Android with 10.3 Rio

Today, I have a webinar on Getting the Most out of Android with 10.3 Rio. I want it to be a bit of a State of Android development today, as well as a What’s New in 10.3 Rio for Android. During CodeRage 2018 presented on what’s new in 10.3 Rio around Android. That session evolved into this webinar.

You can access the slides directly too.


Here is the Q&A log. I’ve gone back and typed answers to all the questions and included links too when possible. I may have edited some questions for length or clarity. The recording of the Q&A failed, and despite trying to recover it I wasn’t able to.

  • Question: what about Samsung Tizen os mobile? I think it’s different than Android OS
  • Answer:
    • When I worked for a large PC manufacturer, it was common for companies to tell Intel they were looking at AMD CPUs as a bargaining technique
    • Samsung mostly uses Tizen as a way to tell Google that they have options aren’t too attached to Android
    • Abandoning Android compatibility and ecosystem is dangerous
  • Question: and what about Android Intel processors or Android emulator with Intel Atom (x86)
  • Answer:
    • Intel’s Atom processors made a short appearance in Android devices 
    • They were x86 instead of ARM base 
    • Android 4.4 KitKat included libHoudini to provide ARM compatibility 
    • ARM compatibility was required because of widespread native NDK apps 
    • Most games include native NDK parts 
    • Discontinued for Android in 2016
  • Question: 8.1 Oreo not yet available for S8+
    • Answer: That is unfortunate, I thought it was. I recently read that Android 9.0 Pie is coming.
  • Question: In case I need an external Android library (jar file) included in my project, what should I do?
    • Answer: Check out the DocWiki for information. But you can add the JAR file in the Project Manager under Targets -> Android -> Libraries and then use Java2OP to create a JNI Bridge file. There is good information in the DocWiki
  • Question: Will there be the same webinar for iOS?
    • Answer: Maybe. I’m not as familiar with iOS, but I’ll see what I can do.
  • Question: Just a Note that Huawei also has a Dex equivalent and it seems to work better than Samsung’s. Please don’t ignore that
    • Answer: Very cool! It looks like it called EMUI Desktop on their HUAWEI Mate 10
  • Question: I am trying to use Drag and Drop to re-sequence TListView items and cannot find any relevant examples. (only things moving panels etc). how would I go about this?
    • Answer: I’ve not tried, but I’ve seen it done. I would treat the ListView items as individual items like panels and then drag those. On drop just look at where it as in the list and change the index.
  • Question: LivePreview are available somehow for Delphi CE?
  • Answer: Yes, just build it and install it. You can find the source here 
    • C:\Program Files (x86)\Embarcadero\Studio\20.0\source\Tools\FireUIAppPreview\
    • and more information on using it DocWiki
  • Question: Are there examples of how to make accepting permissions and explain why needed?
    • Answer: In the DocWiki and I covered it in the webinar.
  • Question: Receiving “Can’t open socket: Permission denied. Exiting” message when trying to debug an Android app. Running Android 8.0. This has been a problem since 10.2.
    • Answer: I just tested this with Rio and a Note 9 running Oreo 8.1 and it worked fine. There was a bug in Android 8.0 that impacted all debuggers. You can find more information on Marco’s blog post.
  • Question: Why does Delphi take so long, literally 5+ minutes, to recognize an Android device connected, via USB, to my laptop? Windows recognizes the device immediately and I’m able to browse the device within Windows file explorer. Clicking the refresh devices button has no effect. Is there a way to speed up this device recognition process?
    • Answer: Odd. I’ve not seen that. If you run ADB DEVICES from the command line does it recognize it? If not then that would be an issue with the Android Debug Bridge (ADB) so could be related to your device or the ADB USB driver. The single physical device has multiple devices that Windows recognizes. One is the MTP device for transferring files, the other is the ADB device for debugging. So just because windows recognizes the MTP device doesn’t mean it has recognized the ADB device yet. What device is it?
  • Question: Re: Delay recognizing device: Device is a Samsung Galaxy S8+. Also tried an HTC One M7 with the same result.
    • Answer: Did you try ADB DEVICES from the command line? It could be a Windows issue.
  • Question: Re: Open Socket error: Android version 8.0. Device Samsung Galaxy S8+. Running Delphi Rio 10.3 So there’s no workaround? Given the current route that Android updates arrive at devices: Google -> Manufacturer -> Telcom -> Device means that I’m stuck with no debugging for potentially years … already been ~6 months? Debugging is the reason I’ve invested in Delphi.
    • Answer: That was a bug in 8.0 Oreo that was fixed in Android 8.1 – it wasn’t specific to Delphi. Unfortunately, we don’t have any control over the Android OS or what Samsung installs on their devices. Wish we did. 
  • Question: What’s the best way to end an Android app?
    • Answer: Best practice on Android is that you don’t close your app, but let the OS manage that. If you need to though, then just call Close on your main form like you would on another platform. You could also try Application.Terminate and Halt.
  • Question: Just want to say that this has been an excellent seminar. Thank you for putting it on.
    • Answer: My pleasure. Glad it is of value.
  • Question: what are the sound capabilities in RAD Studio for Android?
    • Answer: You can do quite a bit. Anything that Android supports (which is a lot). There is a media player component that comes with FireMonkey. Take a look at the 4 sample games in GetIt. They have music and sound effects if I recall correctly. The great thing about using FireMonkey is you can get the productivity of all the FireMonkey components, libraries, etc. and then when you need to you can reach down and access the Android APIs just like developers who don’t use FireMonkey.
  • Question: Wouldn’t it nice to have a component for permissions?
    • Answer: The PermisionService makes it really easy, but a component could be useful too I suppose.
  • Question: Where are we with 64 bit for Android? 
    • Answer: R&D is working on it and it is on the Roadmap for later 2019.
  • Question: Give them the coming end of GCM, any plans for built-in FCM components?
    • Answer: Good question. I’ll need to look into that. I know there are some free 3rd party libraries that do that.
  • Question: Hello. where find more info about splash screen? It not clear how to control it.
  • Question: I can’t find LivePreview App on Google Play Store? Does it still exist?
    • Answer: Not currently, but the source ships with the IDE and you can build it and install it yourself. You can find the source here 
    • C:\Program Files (x86)\Embarcadero\Studio\20.0\source\Tools\FireUIAppPreview
    • and more information on using it in the DocWiki
  • Question: is possible to active and android Delphi generated app on both and remain on background sending GPS updates? any sample?
    • Answer: No samples, but I believe people have done it. You would need to be concerned about the battery though. You might need to go directly to the Android GPS API. I would suggest researching Android services on the Android developer site. There are a lot of rules about them.
  • Question: Hello, I’m wondering why for demos all presenters use a mac? Is better have Delphi on a Mac laptop?
    • Answer: I prefer Windows, and most developers I know do too, but Apple requires you to have a Mac if you want to build for iOS, and since I need to demo for iOS too then it makes sense to have just one computer.
  • Question: Ok. It will be great a webinar about to setup Delphi on Mac !!!
    • Answer: There is a good guide in the DocWiki 
  • Question: Is Firebase supported on Rio? from Rad Server?
  • Question: What about GUI test automation for mobile Delphi projects? Is there finally something available for that?
  • Question: 
    • Does the HTTP client library cover all SSL related topics or is there a need for “raw” TCP SSL sockets? If yes, the HTTP client might not be of help.
    • Although Android still supports SSL (Indy libraries), what about the support for the Google libraries (boring SSL).
      • Answer: Check out the new HTTP Client library that was introduced in XE8 – it uses the platform libraries, but don’t know if it supports Google’s Boring SSL specifically
  • Question: Does Fire Monkey support right to left languages like Arabic and Hebrew?
    • Answer: Take a look at FMX RTL. Also, if a 3rd party can do it, then you can do it yourself too. But using their library will certainly make it easier.
  • Question: Huawei is pronounced “hwah way” 🙂
    • Answer: Thanks! I tried to research it, but I am not good at pronunciations. 
  • Question: Are improvements in FMX listed. For example, when saving a TBitmap by SaveToFile, it did not pop up in the media on Android in my previous version. I had to add this programmatically.
    • Answer: I believe it has to do with where you save it and what file format. Save it as a JPEG or PNG and try saving it in a shared location like TPath.GetSharedPicturesPath.
  • Question: No question, just a hint: someone asked for Ranorex and Android. There is documentation on ranorex.com
    • Answer: Cool
  • Question: Google just announced a few days ago “Starting August 1, 2019: All new apps and app updates that include native code are required to provide 64-bit versions in addition to 32-bit versions when publishing to Google Play.” Looks like our apps will be orphaned later this year without a 64-bit compiler – what is the ETA for a 64-bit android compiler?
    • Answer: The  Roadmap has 10.4.x with 64-bit Android planned for “mid-2019”
  • Question: When will we see more common UI features as components (ie. not having to do things manually), such as slide menus, for example.
    • Answer: Like the TMultiView? It is a great common UI component that was introduced in XE7
  • Question: Can the location sensor be used in an Android service now?
    • Answer: I personally haven’t tested it . . . You may need to research the Android platform limitations on using location services in the background because of battery consumption issues. 
  • Question: how can we handle the android permission requests?
    • Answer: It is covered in the DocWiki and here is a sample in the location samples folder
  • Question: Did I understand correctly that there is a C++ Builder community edition accessible and free for any non-commercial use? (i.e., creating apps for personal use and for open-source distributed apps?)
  • Question: Doesn’t RAD Studio (or C++ Builder) have its own emulator to “test” apps on *all* platforms in a more-or-less automatic way? (assuming that the emulation is faithful enough)
    • Answer: We used to offer a bundle deal with MacInCloud but it didn’t get enough use to justify continue it since most people use devices. You can use the Android emulator but it isn’t great, and there are services that let you test on devices in the cloud. Samsung offers one too specifically for their devices. I’ve also heard some people have good luck with using Bluestacks, but I haven’t tried it. There are a lot of options.
  • Question: Speaking of how iOS is so different and has such different nuances compared to Android…
    • Answer: There is a lot you can do with a complete multi-platform approach, but then there are specifics to each platform you can take advantage of. For example, your desktop has a larger screen, and more input and output options. A pure multi-device approach does a lot and makes you really productive, but then the great thing about Delphi, C++Builder, & FireMonkey is you can also take advantage of platform-specific features and APIs. Kind of a best of both worlds approach!
  • Question: Thanks!
    • Answer: welcome!
  • Question: but there is a lot of devices that still running 8.0! Even Samsung …
    • Answer: Yes, it is an unfortunate bug in Android 8.0. Samsung says they have an update coming, and I hear the beta is already available. Have you tried that?
  • Question: What about 64-bit on Android, iOS, and macOS?
    • Answer: iOS 64-bit has been available for a while, bot macOS (10.3.x) and Android 64-bit (10.4.x) are on the roadmap for release this year. 
  • Question: what is the best way for FireMonkey mobile app to work with DB (on a server). REST or FireDAC? Or something else?
  • Answer: 
    • The best way depends on your goals and the scenario. 
    • I would recommend starting with RAD Server (EMS) using FireDAC to connect to the server database and then connect to RAD Server from your mobile app. 
    • You could also use DataSnap in the same situation (RAD Server is more of a turnkey, while DataSnap lets you build it from scratch so more flexible). 
    • If you don’t control the server then if the server is exposing the data over REST then you can use the REST Client libraries  or the BAAS libraries 
    • Although if it is on Azure or Amazon Cloud then use the cloud libraries 
    • You could also use DevArt’s UniDAC to connect directly to some databases from the mobile app
  • Question: Hello, what is the best way to show forms and destroy it for android application?
    • Answer: You can show and destroy forms just like you would on other platforms, or you might consider using frames on a Tab Control. Also, take a look at TFrameStand which is available in the GetIt package manager
  • Question: Is C++Builder Community Edition available for macOS?
    • Answer: Yes, it can target macOS. The same features as C++Builder Professional
  • Question: Is the size of the executable file for Android, prepared in FireMonkey still a problem?
    • Answer: It never was a problem. A “hello world” app in FireMonkey is larger than an equivalent app in Java because FireMonkey is including a lot of other additional libraries and features for building more complicated apps. There is a lot you can do to make a FireMonkey app smaller, but you give up functionality. If you look at real apps you will see that a Java based app and a FireMonky based app are much closer to the same size.
    • Take a look at this Anatomy diagram for more information. 
Anatomy Of A Delphi 10.3 Rio FireMonkey App from FMXExpress.com?
Anatomy Of A Delphi 10.3 Rio FireMonkey App from FMXExpress.com
  • Question: When will there be support for 64 bit Android?
    • Answer:It is on the roadmap for 10.4.x this year (2019) 
  • Question: Jim: When will Update 1 be available for Rio?
    • Answer: When it is ready. I expect it will be soon, but I can’t say specifically when.
  • Question: What are the critical target versions that should be tested?
    • Answer: All of them? 😉
    • You should be testing on Oreo 8.1 (the target SDK version) and probably Marshmallow (the minimum SDK version) too.
    • You should test on as many devices and OS versions as you can.
    • Pay attention to the Version Distributions Dashboard on the Android site to see what versions are most popular  
    • You can also follow other sites like to see what versions and devices that are popular
    • It can also depend on your app and your user base. Maybe you are targeting a specific region or tablets.
    • Then select the targets that give you the largest coverage.
  • Question: Best Book for quick start to sophisticated Android apps?
  • Question: Timeline for support of WatchOS from Apple?
    • Answer: Both WatchOS and AppleTV require apps published to the app store are in an intermediate format that Apple hasn’t published. 
    • I believe you can still build apps to deploy directly the platform though. 
    • Those platforms are not on the roadmap.
  • Question: I received this from Google: Ensure that your app supports 64-bit devices. Does Rio support this?
    • Answer: 64-bit is on the roadmap for mid 2019 
  • Question: For a Delphi Windows application to access files on your Android phone connected via USB. See MTP13.zip
    • Answer:Useful. That is using the PortableDeviceApiLib Type Library, good idea. You could also do it via ADB if you enable debug mode on the device.
  • Question: Why don’t forms have an option to auto create?
  • Question: How to send SMS from an Android app?
    • Answer:Yes there is sample code online although I haven’t tested it and it may need to be updated.
  • Question: Is there a easy way to get some values from a record from a local website
  • Question: Please address how to read and write external files from/to the SD Card.
    • Answer: That isn’t something I was planning to cover, but I will test it and post to later.
  • Question: Is adding other android SDKs to 10.3 fixed – had a hard time with 10.2?
    • Answer: I’ll blog about it some more. It is pretty straight forward, but there are some details in the DocWiki 
  • Question: I miss the DBaware components from VCL in FMX. How can I get Design time data?

Here are some interesting statistics I originally didn’t include because of time . . .

Android � Logos Download
Android statistics and facts
  • 85% of the global mobile operating system market runs Android
    • 62% of US,  76.4% of China, & 25% Enterprise markets
  • 37.93% of all devices connected to the Internet
  • 70% of tablet market
  • 400+ manufacturers with 4000+ devices on 500 carriers
    • 600+ devices launched in 2015 alone
  • The average Android smartphone user
    • Touches smartphone 2,617 times a day
    • Has 95 apps installed, but only uses 35 apps daily  
    • Deletes unused apps after 12 weeks
  • 34% of US smartphones are by Samsung (running Android)

Android Statistics Sources: 

I pulled a couple of graphics from my presentation that I thought were interesting and that you are free to share. (Select an image for the larger version.)

Categories
10.3 Rio Android FireMonkey News

Android Z-Order, Native Controls, and 10.3 Rio

Z-order represents stacking controls
Z-order represents stacking controls

Before 10.3 Rio when you used a a platform-native control, like TWebBrowser or TMediaPlayer, you were not able to put other controls on top of them. That stacking of controls is knowns as Z-Order. This was especially annoying when you were using them with the TMultiView (one of my favorite controls), because the drawer would slide out under instead of over the platform-native control. There were ways around it, but it was still frustrating.

In XE7 we introduced the ControlType property for iOS, and then in Seattle we brought it to Windows. Setting it to Platform switches a FireMonkey control to a platform-native control at runtime.

Now with the upcoming 10.3 Rio release the ControlType property is coming to Android, and it is brining two significant benefits: More Native Controls, and corrected Z-Ordering.

More Android Native Controls

The TWebBrowser, TMediaPlayer, TBannerAd, and TMapView are always platform native controls (they are rendered by the underlying Android OS and not by FireMonkey.) But in 10.3 Rio there are 4 new controls that are optionally platform native.

TSwitch component

That means when you set the ControlType property on these controls they will be rendered by the Android system instead of FireMonkey. You may notice some slight changes in the way they look and work because of this.

This is especially important in the TEdit as there are certain behaviors that are attached to the way users provide keyboard input and edit text. Here are some of the advantages your users will now have when you use a ControlType of Platform with your TEdit

  • Auto-Correction: Words are suggested while typing, these can be used by clicking on the space bar.
  • Define: You can select a word and click on Define to see the definition of such word in the dictionary.
  • “.” Shortcut: Double tapping the space bar inserts a period followed by a space.
  • Text Shortcuts:? That will expand into the word or phrase as you type.

Some of these behaviors vary from one Android platform to others (for example Samsung has a Clipboard feature). You can configure these settings on your Android devices in Settings > General > Keyboard.

Native Aware Android Z-Ordering

Additionally many controls now are able to handle a Z-Order over a platform native control. Now you can put control buttons over your TMediaPlayer for example. These controls have a ControlType property that when you set it to Platform it will maintain the Z-Order with other platform-native controls.

Setting their ControlType to Platform doesn’t make these platform-native, it just makes them work correctly with other platform native controls.

What’s Next?

10.3 Rio is in beta (which means these features are subject to change) and available to update subscription customers. Once it is released you can learn more about all of these features in the DocWiki. Also, if you are already using Platform native ControlType on iOS or Windows then those control will take advantage of the Android Platform native ControlType right away!

Android Z-Order and the Native Controls - Coming soon to a RAD Studio 10.3 Rio Near you!
Categories
iOS News

The April 2017 Tokyo Hotfix Works with the new Xcode & iOS

Apple pushed out a new Xcode and iOS this week with WWDC. Naturally I updated and tried it. Xcode version 8.3.3 (8E3004b) and iOS version 10.3.2 (14F89). I’m running 10.2 Tokyo with the April 2017 Hotfix and it all worked as expected. I deployed to my iPad and the iPhone simulator (I don’t have an iPhone anymore, upgrade to a Pixel XL!)

Are you running Toyko 10.2 with the April 2017 Hotfix? There are updates coming too. Check out the roadmap to see what is planned for 10.2.1 & 10.2.2. Great new features and a lot of fixes too!

Categories
Android Cloud FireMonk iOS macOS REST TMS

Using TMS Cloud Pack to Integrate Your Apps with the Cloud

I’m a huge fan of the REST Client Components included with RAD Studio. They make it really easy to take advantage of the huge amount of REST services available online.

Here is a quick video of me using the REST Client components to build a REST Client in 5 minuntes.

One thing about more complex REST APIs is REST isn’t a strict protocol like SOAP, it is more of a philosophy in building an API. This usually means I spend a few hours looking at each REST API that I want to work with. Authentication is the thing that really changes from API to API.

That is where the TMS Cloud Pack comes it. They make working with some of the standard large APIs a breeze (get it, a breeze when I am talking about clouds!?!) You just need to setup an API account and get your API key and provide it to the component and it does the rest.

I got a license for TMS Cloud Pack from TMS Software. I was surprised at first that it didn’t work with FireMonkey. It turns out there is a seperate Cloud Pack for FMX, although they offer a Cloud Studio that works with a variety of tools (including IntraWeb!)

When I started working with it I realized it made sense to have a different VCL and FMX version of the components because they include a browser window that is used when the user needs to authenticate for the OAuth services.

Besides the different browser window I found the FMX and VCL versions very simialr in functionality. So it is just a matter of what frameworks and platforms you want to work with since the FMX versions add support for macOS, iOS and Android in addition to the Windows support in the VCL version.

With the power and variety of REST APIs available today, you really should look at leveraging them in your apps, and if it is one of the APIs that TMS supports, then you will want to use it!

If you are new to TMS Cloud Pack then join us for our webinar on Tuesday the 21st of February and check out the TMS Cloud Packs in the GetIt Package manager.

See you online!

Categories
Android Internet of Things iOS Mobile News

Cool App Contender: HOP (Hunger Obesity Prevention) App

Embarcadero Cool App ContestThere were a lot of amazing apps submitted for the Embarcadero Cool App Contest. Last month’s winner was 1Password for Windows. Any entries that don’t win one month, are automatically eligible for the next month. We will have our next winner shortly.

In the meantime I thought I would highlight a few of the entries that caught my attention. They are all very cool apps.

Sherwood Middle SchoolThe first one I want to highlight is by two sixth grade girls, Suresh and Safalta, from Sherwood Middle School in Shrewsbury, Massachusetts. They created an app to help tackle two big problems at the same time: Hunger and Obesity.

The idea is brilliant: Educate users on lowering their caloric intake to reduce obesity, and then provide a way for them to donate the money they would have spent on junk food to those who are hungry.

One thing I really liked about this entry is they didn’t start with Delphi. Their school taught them to use Java and Python, and they tried a few different tools. They found they were difficult to use, hard to understand and took a lot more code than they wanted. Then they tried Embarcadero Delphi and found it really easy. As they put it, “Embarcadero provided [an] easy button tool for compiling codes for multiple devices including android, iOS etc. which helped us to develop app quite faster. We are planning to recommend the use of Embarcadero [Delphi] to other kids interested in developing apps.”

They used Delphi with FireMonkey, LiveBindings, FireDAC and SQLite to build their app for iOS and Android. Watch their video as they explain obesity and how their app works.

I’ll share some of what they wrote in their entry too.

Obesity in children and young adults is a global health problem among developed countries. United States ranks first in the world with 35% of male, 39.5% female children, and young adults suffering with obesity. Obesity in children affect an estimated 41 million children worldwide, as per World Health Organization (WHO) and United Nations Children’s Emergency Fund (UNICEF). Obesity leads to major health problems including, type 2 diabetes, high blood pressure, high cholesterol levels, fatty liver disease, gallstones and heart diseases.

Similarly, malnourishment and hunger in poor countries affect 159 million children causing nearly 3.1 million children to die each year in the entire world, as per WHO and UNICEF.

Our goal is to help and motivate kids from developed nations by encouraging them to lose weight by eating less, and use the money saved, to help feed hungry and malnourished children living in poor countries. To achieve this goal, our objective is

  1. To provide a free to all Hunger and Obesity Prevention (HOP) App to help children with obesity, encourage them to lose weight through making conscious efforts to engage in physical activity, avoid junk food and promote eating healthy foods.
  2. Then provide an opportunity for HOP participants to celebrate their achievement, by pledging to donate 25 cents/pound lost to UNICEF for feeding hungry children, as a motivation to lose weight for greater cause.

Purpose: Overeating and genetic reasons are important factors in causing obesity. Eating more food, particularly junk food and lack of physical activity leads to accumulation of excess calories to store as body fat, which then results in weight gain and obesity. Obesity is preventable or reversed by consciously taking control of what you eat, and burning excess calories from the body by exercising regularly.

Our long-term goal is to make an advanced version of HOP with ability to take pictures of food/snacks/drinks and estimate calorie contents, select meals and retrieve calorie information from restaurant menus to keep track of calories consumed each day. In addition, we plan to integrate activity-monitoring apps like “Fitbit” or “Pacer” and precisely monitor the progress with physical activity in fighting obesity.

This basic version of HOP is intended to determine if the user is obese, then set goals to lose weight, track physical activity, dieting plans (such as healthy eating, avoiding junk food and salty snacks), record weight over a period of time. When the participant succeeds in losing 1 pound of their body weight, it means they have cut or burned 3500 calories.

Now we ask the participants to make a pledge to donate the unused calories for saving the lives of starving children. By pledging to do so, it gives a cause for participants with obesity to lose weight and hope for hungry children fighting to survive.

UNICEFOur HOP App designed to pledge 25 cents to UNICEF on their behalf as a way to celebrate their achievement. However, in future users will have options to donate to any charitable organizations that are associated with feeding hungry children. Our mission is to help ending obesity and hunger in children and give them the gift of life, through motivating obese children to SHARE CALORIES with hungry children.

I’m really excited to see their app develop, and it is great that they chose RAD Studio and Object Pascal / Delphi to build this. Especially with 10.1 Berlin it includes easy components to connect with health devices like scales, heart rate monitors and cadence sensors.

Good luck to Suresh and Safalta!

Categories
Android Article Mobile News

FireMonkey and the Android Misconception

FireMonkey(300px)When it comes to Delphi, C++Builder and FireMonkey’s support for Android, there are 5 caveats.:

  1. ARM Cortex-A series CPU (not Intel Atom)
  2. ARMv7 Instructions
  3. NEON Technology
  4. GPU
  5. Specific versions of Android

At one point there was some attempts made to make a list of devices that were supported either completely or partially, but new devices were coming to quick to track. This lead to the misconception that FireMonkey apps only run on a very small subset of Android devices.

Since that time there have been a number of improvements to the compiler and the FireMonkey framework. Also the landscape of Android devices continues to evolve and change. Yet I still run into people who believe that FireMonkey still only runs on a small subset of devices. I thought I would provide an update and set the record straight.

Tegra 2 and NEON

Shortly before Android support was added, the Tegra 2 processor was in use. It was ARMv7 and Cortex-A, but lacked the NEON SIMD extension. So what is NEON? NEON is a SIMD (Single Instruction Multiple Data) instruction set. When it was introduced it was an option that some ARMv7 processors included to improve performance. Since it was optional, the Tegra 2 excluded it.

Intel i487 SXIt seems kind of uncertain to have some processors with some features, and others missing them, especially if you require them for your application to run. This isn’t some crazy thing that only happened with Android and ARM. Back in the time of the Intel 486 CPU (right before things went Pentium) some systems had an optional 487 math co-processor. This co-processor introduced some additional x87 instructions that accelerated some floating point operations. Some programs would be faster on a machine with x87 support, and others required it. When the Pentium came out, it incorporated the x87 instructions into most of the CPUs (there are always exceptions).

Pentium MMXThe Pentium didn’t end up being the “One CPU to rule them all” though. Along came MMX Instructions. MMX is a is a single instruction, multiple data (SIMD) instruction set that was optional for some CPUs (where have I heard that before?) Some programs were faster on an MMX enabled CPU, and others required it to run at all. After a few years, most all CPUs, even those made by AMD included MMX instructions. It didn’t end there. New CPU instruction sets are introduced all the time, but it is rare that they get the same publicity that MMX or the x87 set did.

What does all of this have to do with NEON, besides perspective? Well, Neon is now part of the ARM standard. The new ARM chips in modern Android devices include Neon. They don’t even both listing it as a feature because it is assumed. The R&D team bet on NEON and they won. Since the compiler takes advantage of Neon instructions it is faster than it would be if they hedged their bets and ignored Neon.

Enter the GPU

NVidia 6600GT GPUMuch like the x87 was a separate processor that augmented the system performance, there are many other processors in your computer, specifically around audio and graphics. The big thing about the GPU is that it not only beefed up the existing graphics co-processors, but it took on the 3D and texture operations and ran them through a massively parallel architecture. The original GPU that I had was actually a separate board in addition to my graphics card. Today they are mostly integrated.

On Android they typically go with a System on a Chip (SOC) that includes the CPU, GPU and a number of the other electronics.

The Rise and Fall of Intel Atom

ARM logoARM is an open standard CPU manufactured by many different chip makers, often times under their own brand. A few manufactures include Qualcomm, Texas Instruments, Samsung and even Apple (for their mobile devices). ARM logoIntel wanted a piece of the mobile processor action, but instead of just implementing ARM they introduced the Atom processor. It still used the x86 instruction set of the desktop CPUs, but was designed to be more energy efficient. They put them in Windows tablets and Android devices.

This introduced another division in the Android landscape. There were two different processor architectures. Since most Android apps were written with Java and ran in a virtual machine, it wasn’t a huge deal. Except for games. Most games use native code for performance reasons, so that required either the game to include both ARM and Atom code and libraries, or the game just wouldn’t work on Atom.

Harry Houdini 1899Enter libHoudini. Intel realized that mobile gaming was a big part of Android, and the fact that you couldn’t play a lot of popular games on Atom devices wasn’t good. So they created libHoudini, a proprietary ARM translation layer that translates ARM instructions into x86 instructions for the Atom processor.

libHoudini was around for a while, but around Jelly Bean or KitKat it became standard on Atom based Android devices. This resulted in ARM native apps just working on Atom devices.

Embarcadero was actually in discussions with Intel. There was talk of making an Atom targeted compiler for Android, but work was also done to improve compatibility with libHoudini. Atom was never officially supported (mostly because the market share was too small) so the Android app packager includes a check to say it didn’t work with Atom processors. But you can remove that checker and your app will probably run great on most Atom devices.

While Atom never had a huge share of the market, it looks like it is going to have even less as Intel has cancelled their next Atom processor line.

Android Versions

Unlike Apple, new version updates don’t tend to roll out as fast on Android devices. This means you typically encounter a few different versions of Android running in the wild. It isn’t all that bad though. In my opinion, Ice Cream Sandwich (API 15) was really when Android came into its own. It was Honeycomb (API 14) that finally gave tablets some serious love, and ICS merged those new features back to phones. Anything before ICS is really legacy at this point (at least in my opinion). Android tracks the popularity of Android versions on their Developer Dashboard.

Android Platform Versions Chart
As of May 2, 2016

Ice Cream Sandwich and older only account for a total of 4.3% of Android devices. While there are feature differences between the top 3, nothing is too revolutionary as to make the others obsolete yet.

A Thousand Flowers

Unlike iOS, where Apple is the only company to make devices that run it, Android is EVERYWHERE! I guess I’m kind of a collector of Android devices. I owned the first Android powered watch by WIMM and even created a 6 sided dice app for it. Now that Delphi supports Android I love testing it on different Android devices. Here is a list of my findings

  1. Android Wear – I’ve tested 4 or 5 different Android wear devices, including the Moto 360, and they all worked flawlessly with FireMonkey.
  2. Google Glass – Again, worked out of the box with FireMonkey. We even later added official support. Unfortunately Google is reimagining Glass right now, but I suspect when then new version comes out it will work great.
  3. Epson Moverio BT-200  – Similar to Google Glass, but has two independent translucent lenses so it can do 3D. Runs Android Jelly Bean and works with FireMonkey right out of the box. There is a BT-300 coming soon.
  4. Ouya – This was the Android gaming console that was going to change the world. It ended up under delivering, and then not evolving fast enough. It does however run FireMonkey just fine, and I know a few developers who used it for creative projects.
  5. Amazon FireTV and Fire TV Stick –  Designed to work with your TV and running Amazon’s own version of Android. Again worked like a charm with FireMonkey.
  6. Amazon Fire Phone – I think this is a pretty cool device, a shame it didn’t catch on. Also runs FireMonkey apps fine.
  7. Amazon Kindle Tablets – I’ve not tested these, but I know people who have. Again it runs a different flavor of Android. From what I hear some people had to update their OS to get it to work with FireMonkey, but it did work.
  8. BlackBerry Phone – Yeah, I went there, and so did FireMonkey. It worked too, although there are some idiosyncrasies about the OS that show up when you invoke the share sheet. I originally tested it on the BlackBerry OS, which supports Android apps, but now they’ve gone full Android.
  9. Windows Phone 10 – My Windows Phone wouldn’t install the right preview of Windows 10, but Marco had better luck than I and got FireMonkey apps running on Windows 10 Phone under the Astoria bridge. Then Microsoft discontinued it. Windows Phone never had much market share, and continues to dwindle.
  10. Huge collection of tablets and phones, including one with an Atom processor – they all worked (except that one old Tegra 2 tablet that ran Gingerbread).

Since Android is everywhere I’d wager that there is no Android app that actually runs on every single Android device out there, I don’t care what you wrote it with. Now if someone wants to prove me wrong, that is fine, I suspect different Android devices will be released faster than we can test them.

Conclusion

Let’s run through those requirements again and see how big of an impact they really represent.

  1. ARM Cortex-A series CPU – Atom was never big, and is on its way out. Most everything else is ARM Cortex-A (or newer / compatible).
  2. ARMv7 Instructions – ARMv6 is either really old, or used in a micro device like a beacon or some other IoT device. Not in any Android devices. Oh, and ARMv8 is the big thing now. It is 64-bit and runs FireMonkey apps fine.
  3. NEON Technology – Like I said, it is part of the standard now, so unless you have an old Tegra 2 tablet (I still have one) then nothing to worry about.
  4. GPU – All of the GPU compatibility and performance issues I know of have been fixed, and GPUs are standard on Android devices (at least ones with a screen).
  5. Specific versions of Android – Only 2.3% of devices have an unsupported version of Android.

So while FireMonkey apps may not run on every single Android device in existence, most apps don’t and no app needs to. FireMonkey apps to run on the vast majority of them, and that is what matters.

Categories
Android iOS Mobile REST

REST Client Video Challenge

Yesterday, I mentioned I built a REST client and deployed it to iOS and Android inside 5 minutes. Someone asked me to make a video actually showing how it was done. So here it is showing a simple REST client built and deployed to iOS 9.1 and Android 6.0 Marshmallow.

Since I am using SpitCast, and it doesn’t offer an encrypted endpoint for its REST service, I had to modify the Info.plist to allow that on iOS 9.

Could I do it faster without the video recording and explanation? Yes, but I think you get the idea. Delphi makes building multiplatform REST clients really, really easy.

I’m curious to see someone create a client app using other general purpose development tools to connect to a REST service and too see how long that takes.

If I wanted to connect to a different end point to pull down more information on an individual surf spot I could that by handling the OnItemClick event for the List View.

If there is interest I’m happy to share my Sync-Timer source code.

Categories
Android Conferences

Android Services Presentations and Workarounds

Another round up of Android Service related resources.

For starters here are my slides from my Android Services presentation in Brazil.

Creating Android Services with Delphi and RAD Studio 10 Seattle from Jim McKeeth

You can also download the Workarounds and fixes for the Java templates and Android Manifest from CodeCentral.

You can catch a replay of Julian Mesa’s session from CodeRage X

And check out my other Android Services posts.