Programming on Harbour for AndroidI present here one small simple Android application which, however, can be helpful:
Download h4aFirstApp_v6.zip - sources.
Download h4aFirstApp.apk - ready for installing to Android device.
It is a demo program, but you can create on its basis something useful for yourself. For this we need to rewrite to fit your needs the \h4aFirstApp\source\testhrb.prg ( a source file, written with Harbour ) and rebuild a package h4aFirstApp.apk, using the \h4aFirstApp\build.bat (Windows) or \h4aFirstApp\build.sh (Linux).
But before you need to download and install Java Development Kit - JDK ( don't confuse with JRE - Java Runtime ) and Android SDK Tools. You may install the full Android Studio, but it is not necessary. After installing the Android SDK Tools you need to run SDK Manager и install additionally some components.
Then you will need to edit the \h4aFirstApp\h4a\setenv.bat - register there your paths to the installed products.
Testhrb.prg must contain at least two functions:
- FModList() - returns a string that is displayed on the main screen as a menu. Menu items must be framed on both sides with **
- FModExec( iMod ) - implements menu items, should return a string that is displayed on the screen of the application.
- h4a_HomeDir() - returns the application home directory
- h4a_CalcExp( cExp ) - returns the result of executing of the cExp, which may include any Harbour functions and operators
- h4a_LS( cDir ) - returns a string - list of files in cDir
- h4a_isInternetOn() - checks the Internet connection
- h4a_wrlog( cString ) - writes to a system journal ( it may be read then, if the program is executed on emulator )
- h4a_webload( cHtmlPage ) - loads a new web page to the already created WebView
- h4a_getsysdir( cType ) - returns public directory of a certain type ( "ext" - base directory External Storage, "doc" - Documents, "pic" - Pictures, "mus" - Music, "mov" - Movies, "down" - Downloads, "ring" - Ringtones )
Even such a simple structure allows to implement useful features - for example, a set of reports on the current status (info about the shipment of goods, the state of bank accounts, balances in warehouses, etc.).
- Version 6: h4a_webload( cHtmlPage ) and h4a_getsysdir( cType ) Harbour functions added.
- Version 4: Mastering the technique of calling Java methods from Harbour and debugging techniques - added Harbour function h4a_isInternetOn() to determine whether there is an Internet connection and h4a_Wrlog( sText ) - write debug messages to a log for saving to a file using adb shell logcat. Scripts are slightly modified.
- Version 3a: Scripts for building package under Linux added, fixed a bit scripts for Windows.
- Version 2: Added additional support for hrb updates. An update module is included in testhrb.prg, it allows to get new hrb files from this site. Besides, a problem solved, related to some Android feature - it doesn't close an application after closing a main window (Activity).
And yet another links. Projects on the Github: h4aFirstApp и set of scripts to create libharbour.so for Android. And this is a little tutorial about h4aFirstApp setup from Roberto Lopez.
(not be shown publicly)