I substituted for David I. yesterday for Developer Direct Mobile Summer School on Lesson 5: Connecting Mobile and Desktop together using App Tethering. The Summer School landing page and David’s blog maintain a list of downloads for all the previous lessons, but here are the resources from my session in the meantime.
I’ll post the replay videos here when they are available too.
You can download my slides and code samples from Code Central. I believe I fixed the issue where some people were not able to download it.
Here are the links to more information on App Tethering:
Here is the Developer Skill Sprint I did previously on App Tethering
And this is Al Mannarino’s C++ Mobile Day session on the topic
And some blog posts on the topic too:
There was some interest in the code sample that bypasses App Tethering’s autodiscovery to connect directly to a specific IP address. I’m working on getting that tested before posting it. Leave a comment if you are interest and I’ll see that you are notified when it is ready.
For my Developer Skill Sprint I was originally scheduled to show how to do a Google Glass Voice Trigger. That is pretty cool because it allows you to launch a Google Glass app with your voice, but I decided to expand on that to also show how the Google Glass app can be launched with the results of additional voice input, as well as how to take dictation and do text to speech everywhere else in Android.
I’ve still got a lot of work to do on the components, but they work as is for now. If you want to modify the component code then take a look at my Skill Sprint and blog post on the Android JNI Bridge.
By creating a custom Classes.dex you can get access to 3rd party Java JAR APIs from your application. For my Integrate More Android with a JNI Call to your Android App Developer Skill Sprint I created a demo app that demonstrates creating a custom Classes.dex. This is a new feature in XE6 and Appmethod 1.14. [Download the demo] [Download the slides] The Demo app uses the Base64Coder JAR file (included). To build the demo:
- Examine the createdex.bat file to make sure it refers to the correct location for your dx.bat utility and the fmx.jar & android-support-v4.jar files.
- Run the createdex.bat file to create the classes.dex file which includes the two jar files above, plus the base64coder.jar file.
- Double check that the Deployment Manager references the new classes.dex and not the old ones, and that the remote path is “classes\”
- Notice that the android.JNI.Base64Coder.pas file wraps and exposes the methods of the base64coder class.
- Run the app on your Android device and verify that it works as expected.
The Base64Coder.JAR is Android specific, so it will not work on iOS or Windows. Some additional notes from the Developer Skill Sprint: Some useful units for making JNI calls
- Androidapi.Jni – Java Native Interface type definitions
- Androidapi.JNIBridge – The JNI Bridge
- Androidapi.JNI.JavaTypes – JString and other common types.
- Androidapi.Helpers – JStringToString and other useful conversions.
- FMX.Platform.Android– Useful platform methods like GetAndroidApp, MainActivity and ConvertPointToPixel
- Others useful units: Androidapi.AppGlue, Androidapi.JNIMarshal, Androidapi.JNI.Embarcadero
- For more see: C:\Program Files (x86)\Embarcadero\Studio\14.0\source\rtl\android (Object Pascal) and C:\Program Files (x86)\Embarcadero\Studio\14.0\include\android\rtl (C++)
You will want to make use of Conditional Defines in Object Pascal and Predefined Macros in C++. In my blog post on Android Settings I showed how to make a JNI call with Object Pascal, but you can also look at the DeviceInfo Mobile Code Snippet in both C++ and Object Pascal. To create your own JNI Bridge wrappers, look at the source code in C:\Program Files (x86)\Embarcadero\Studio\14.0\source\rtl\android (Object Pascal) and C:\Program Files (x86)\Embarcadero\Studio\14.0\include\android\rtl (C++). You can also consider the following 3rd party utilities:
If you just want to include standard Android APIs then check out the FMXExpress (also an Embarcadero MVP) project on GitHub that includes all the Android APIs. Here is the video replay of my skill sprint
Also, check out Brian Long’s video on accessing the Android API with XE5
As part of the free Developer Skill Sprint on REST & JSON here are my slides and sample source code. Appmethod, RAD Studio, Delphi & C++Builder XE6 ship with the Desktop sample RESTDemos sample which includes examples for:
- Google Tasks
- Plus Some others
That includes both OAuth1 and OAuth2 usage. My Dropbox demo is a mobile app written in both C++ and Object Pascal. It uses OAuth2 and the mobile TWebBrowser to perform the authentication. You can view and download the slides as well. Useful links:
So upgrade to XE6 or download the trial today.
Here is the video for the Skill Sprint:
I’m joining Nick Hodges in King of Prussia, Pennsylvania for the Philly.NET Code Camp 2014 Refactored. I’ll be showing off the latest version of Appmethod, including the Free Forever C++ for Android version. Astute readers may have noticed that my sessions are not on .NET, and the conference isn’t actually in Philadelphia. I’m guessing that is the “Refactored” part.
If you are in the area, stop by and say hi. They still have tickets for the two day event where you can catch all three of Nick and my sessions, and maybe a few others if you are interested.
Michael Feathers defines “legacy code” as “code that has no unit tests”. Without unit tests your code is fragile, hard to change, and unreliable. Unit testing is the only way that you can be sure that your code does what it is supposed to do.
This talk discusses the basics of Unit Testing by defining terms, discussing what Unit Testing is and is not, and talking about the best techniques and practices for writing unit tests.
All the demos will be in Delphi code, but the principles all remain the same: There no longer is an excuse for not writing unit tests.
I plan on finding a good authentic Philly Cheesesteak Sandwich while I’m there too!
FireMonkey offers a lot more alignment options than those offered in the VCL. The Alignment aligns the control within its parent, setting anchors, size and position. The Default is None. To make it easier to think about them, you can group the different types of alignments.
- Anchor and fill along edge – these are 4 of the alignments you are most likely familiar with.
- Like the above, but takes precedence over other alignments
- MostBottom, MostTop, MostLeft, MostRight
- Fill parent, but preserve aspect ratio – very powerful, especially when applied to one of the new layouts, like the TScaledLayout.
- Resize only on one axis (width or height) to fill that axis of the parent and optionally centered
- Vertical, VertCenter, Horizontal, HorzCenter
- Client – Fills remaining space not occupied by other pinned controls.
- Contents – Fills entire client area of the parent overlapping other controls.
- Center – Just moves to the center without resizing.
- Scale – Maintains relative size and position relative to the parent as it resizes.
Checkout the full DocWiki pages for more details on FMX.Types.TAlignLayout and Vcl.Controls.TAlign.
There are a lot of interesting Delphi projects showing up on GitHub. GitHub offers a convenient Download ZIP function, not to mention a very easy to use Windows Desktop Client that has full support for managing local repositories, syncing them to GitHub and accessing GitHub projects via Cloning in Desktop.
Sometimes it is nice to just open the project in your IDE of choice directly from GitHub. Turns out this is just as easy as 1-2-3. Right above the Clone in Desktop and Download ZIP buttons there is a checkout URL with support for Subversion. Simple click Subversion, then click copy URL and your can then open the GitHub project directly from the Delphi or RAD Studio IDE.
This maintains the revision history locally so you can browse it from the history tab, but it doesn’t appear to allow checking changes back in.
You probably want to update the SVN client RAD Studio uses. This is easy enough too. Just download and install the Colab SVN 32-bit Windows client (don’t get 64-bit or Edge) and install it normally. Then edit your Registry and browse to “HKEY_CURRENT_USER\Software\Embarcadero\BDS\14.0\Subversion” and add a string value named SvnDllDir. This value of SvnDllDir should be the path to your SVN client install. Something like “C:\Program Files (x86)\Subversion Client” (without the quotes).
If you don’t like the fact the Colab Subversion site requires a login, there are other sources for download the Subversion command-line client. Just be sure you get the 32-bit version since the IDE is 32-bit. You may have luck with with the command-line tools that come with TortoiseSVN, or I’ve tested it with the Command-line client from Assembla and found it worked fine.
New in XE6 is support for VCL Sensors. What better way to show these off then on the 8″ Dell Venue 8 Pro Windows 8.1 Tablet. The VCLSensors sample ships with RAD Studio XE6. I simply deployed it to the Dell Venue 8 Pro and it runs great.
I added one of the VCL Styles to it as well. You can see it running here with my favorite wallpaper. It shows the Latitude & Longitude from the GPS via the TLocationSensor, the motion from the accelerometer via the TMotionSensor and the compass heading + tilt from the compass and gyroscope via the TOrientationSensor.
These sensors behave exactly the same way as the FireMonkey mobile ones do on Android and iOS, but now you can take advantage of them with your desktop applications.
You can also use the Metropolis UI and the tablet optimized styles for a full screen tablet experience on the Dell tablet. Both with VCL and FireMonkey.
I took my code I previously used to control the Parrot AR.Drone and turned it into a reusable component. I added some more functionality to it as well, although there is a lot more to cover. The component is available on GitHub.
It should work with Delphi, C++Builder, Appmethod and RAD Studio on iOS, Android, Windows and OS X. I’d love to hear how it works for you and what you use it for!
Remember the demonstration I did showing how Delphi works great with Ouya? Well, there is a new set top box in town, the Amazon Fire TV. Just like the Ouya, it is a Android powered set top box. So, does it support everyone’s favorite Android development tool? Turns out it works great with Delphi XE6. It uses a wireless ADB connection, so you just need to follow their simple steps to Connect ADB and it shows up in the IDE as the Android device AFTB (not sure what that stands for). After that you can develop and deploy to it just like any other Android device.
When you run your app from the IDE it will popup and run on the Fire TV, but after you exit your app you won’t see it anymore. It appears Fire TV only displays apps that are loaded from their app store on the home screen. Not to worry, you can easily launch it from the Settings -> Applications screen. Simply select your app and choose Launch application.
By default your only input device is the Amazon Fire TV remote.
Simply handle the OnKeyUp event on your form and you will receive events with the key codes vkLeft, vkRight, vkUp, vkDown, vkMenu, vkHardwareBack, vkMediaPlayPause and a key value of 0 for the select, fast forward or rewind buttons. The Home and Voice Search buttons are always handled by the OS. If you choose to handle the vkHardwareBack then set the key value to 0 (or any other value) and the system will ignore it, otherwise your app will exit.
Fire TV also supports a gamepad as well as various other bluetooth input devices, like a bluetooth keyboard, which greatly expands the input options. You also could use App Tethering to tether a mobile or desktop/laptop app to your Fire TV app to provide input and display it on the big screen. Like an image receiver that receives pictures from your mobile device to display them to everyone in the room.
If you download the Fire TV SDK it exposes Game Controller and Notification classes. If there is interest I can post some Object Pascal wrappers for those later on.