It's a framework for Android, a tool designed to write in Harbour applications for Android based devices - just as HwGUI allows you to write in Harbour GUI applications for Windows and Linux. I even thought about it first, as about HwGUI for Android, but along the way decided that it is better to refuse from thoughts to provide compatibility on prg level with applications on other operating systems - too specific is and the Android platform, and it interface, and the nature of the devices that use Android. Take the size of mobile devices, which is unlikely to significantly change as technological advances - just add a normal keyboard, or double the size of the screen - and the device will simply cease to be mobile. Now, imagine how any familiar desktop application with a bunch of widgets will look at this device ... It is clear that the interface of the application will have to be rewritten to suit the standards of mobile devices. And if so, why should we care about full compatibility with GUI libraries for Windows and Linux ? Application code that uses HDroidGUI, in the part which is responsible for the interface will be different from the code of HwGUI applications, although I try to use the most similar syntax.

What to begin with ?

The tools that you need to download and install before you can start using HDroidGUI are listed in the "Android" section.

Download HDroidGUI here or from the repository on Github, unpack and see what is inside it.

And inside we see the following:

The structure of HDroidGUI distribution:

  • buildall.bat, buildall.sh - command scripts for the whole framework cross-compiling, bat - if you do it under Windows, sh - if under Linux.
  • clear.bat, clear.sh - command scripts for deleting the results of compiling.
  • comp.bat, comp.sh - command scripts for compiling of Java - code of the framework.
  • ndkBuild.bat, ndkbuild.sh - command scripts for compiling of C and Harbour - framework code.
  • setenv.bat, setenv.sh - command scripts to set the environment variable to compile the framework, you need to edit it - set the paths, which are correct for your system.
  • jni/Android.mk, jni/Application.mk - makefiles to build dynamic libraries (so) of the "native" part of the framework.
  • jni/libharbour.so - prebuilt Harbour dynamic library, which is used to create dynamic libraries of the "native" part of the framework.
  • static/jni/Android.mk, static/jni/Application.mk - makefiles to build static library of the "native" part of the framework.
  • src/ - the directory for the framrwork sources.
  • src/include/* - header files for Harbour-code.
  • src/prg/* - Harbour and C sources.
  • src/su/harbour/hDroidGUI/* - Java sources.
  • utils/newproject.prg - a source file of an utility for creating a new project.

First, edit the setenv.bat ( or setenv.sh if you have Linux ), setting needed paths there and run buildall.bat ( or buildall.sh ) - HDriudGUI must be compiled otherwise will be issued to report problems.

I would like to draw your attention to the dynamic library jni/libharbour.so, which is included in the distribution. I put almost all Harbour modules there, except those that are responsible for console input/output and few codepages, plus Letodb RDD. Scripts to build the libraries are in repository on Github, you may want to include something else and rebuild libharbour.so. You may need it also, if you want to use the latest version of the Harbour.

after compilation you should see the following files:

Now we are ready to create our first application for Android in Harbour. For this we need to create a new directory with the project, where is all that is necessary for building of apk - and AndroidManifest.xml, and Java-sources, and command scripts to build, and makefiles to build dynamic libraries that will be included with package - yes, Java and Android are not so simple, as simple is the Harbour application. But, fortunately:) we have a special tool, part of the HDroidGUI - already mentioning here utils/newproject.prg; you need to compile it using the Harbour or even just to run it with necessary parameters using the hbrun.

Create your project for Android:

      newproject [hrb] [-path=PATHtoHDROIDGUI] [-pass=cPassword] cFullPackageName

Let's start parsing parameters from the end:

cFullPackageName is the full name of our application.
It is accepted in Java systems to put classes into packages to provide uniqueness of their names. A package is a container that is used for insulation of class names, in order to avoid possible conflicts with other classes with the same names. The names of the packages to ensure uniqueness, it is customary to assign in accordance with the names of your domains ( domains of your website ), and they are indicated in reverse order. So, if your site is www.zzz.org and the application is called MyApp, then the full name of the package is recommended to be the org.zzz.MyApp. In this case the Java - sources should be placed in the directory src/org/zzz/MyApp/. It is therefore important to specify the full name of the application. If there will not be at least one dot, newproject will refuse to create the project.
-pass=cPassword is the password for the apk signature.
Each apk must be signed, therefore it is necessary to specify a password to sign - newproject will include it in the command script, which he will create. If you do not specify the password in the command line, newproject will ask you to enter it at start.
[-path=PATHtoHDROIDGUI] is the full path to HDroidGUI.
To compile your application and create an apk HDroidGUI is needed, therefore, it is necessary to specify the newproject, where it is to include it in the generated command script ( setenv.bat, setenv.sh ). If you do not specify it in the command line, newproject will ask you to enter it at start.
[hrb] - the type of project.
HDroidGUI allows you to create a project of two types:
  1. prg file is compiled into hrb.
  2. prg-files are compiled in the usual way - in object files are built to a binary.

In the first case, the compiled hrb is copied to the directory asset/ of the apk package, and at the start of the program is copied from asset/ in the application home directory of your Android device and runs exactly as it is done in h4aFirstApp - my first attempt to create a Harbour application for Android. I do not see special advantages of this type of project, except that it is faster and easier going and possibly it can be convenient for small applications. To set this type of project, specify -hrb in the command line.

The second option is the default option. Your entire Harbour code is built in a binary module - dynamic library libh4droid.so, which is included in apk. If you, like me, like to use hrbfiles, you can do it in this case, too, - no one is stopping you from creating hrb during program execution, or download precast from your web store.

So, by running newproject org.zzz.MyApp and specifying while execution the path to HDroidGUI and password to sign the package, we will get the directory MyApp with this content:

Now you can start writing the program. The main source file can have any name, not necessarily the main.prg but if you change it, don't forget to edit build.bat(build.sh) - the same thing if you add new files in your project.

Still need to learn the commands and classes HDroidGUI. While the description is not ready, watch the text of example HdCalcul and prg - sources of HDroidGUI.

Comments:       ()       prev.    next.       Add comment
The length of a comment - no more than 4000 characters.
Your name:

Email address:
(not be shown publicly)
Input text from an image: