A HARBOUR ANDROID NETIO CLIENT DEMO WITH HDROIDGUI

I. INTRO

This demo is based on hddbf HDROIDGUI demo by Alexander Kresin.

Since it was created modifying ‘hddbf’ demo, such name will appear when you install (I feel a little lazy today 🙂 ).

This Android client is designed to work with the server created in the previous post.

II. INSTRUCTIONS

To test this demo on a LAN, you must do the following:

  • Run the NETIO server described and downloadable from the previous post
  • Find the local IP address of the machine running it (you can use ipconfig command to get it)
  • Download the .apk linked to this post and install in an Android device.
  • Run the app, enter the address of the NETIO server machine and tap the ‘Retrieve Records’ button. Don’t forget to connect your Android device to the same LAN running the server.
  • To make your server available on the Internet, please, take a look at the previous post. Once configured, you must use the server public Internet address on your Android client, to get your data anywhere!

III. THE CODE

* HDROIDGUI NETIO Client Demo (Roberto Lopez)
* Based on hddbfdemo by Alexander Kresin

#include "hdroidgui.ch"

* All HDROIDGUI apps starts with HDroidMain function...

FUNCTION HDroidMain

LOCAL oWnd, oLayV, oBtn1 , oEdit1 

* We create the main window

INIT WINDOW oWnd TITLE "NETIO Client Demo" 

	* In a vertical layout the widgets are arranged from top 
	* to bottom vertically
	
        BEGIN LAYOUT oLayV SIZE MATCH_PARENT,MATCH_PARENT

	* We will add an editbox to specify the server address 
	* and a button to invoke GetRecordSet() function
	
		EDITBOX oEdit1;
			TEXT '' ;
			HINT 'NETIO Server Address' 

		BUTTON oBtn1 ;
			TEXT "Retrieve Records" ;
			SIZE MATCH_PARENT,WRAP_CONTENT ;
			ON CLICK {||GetRecordSet(oEdit1)}

	END LAYOUT oLayV

ACTIVATE WINDOW oWnd

RETURN NIL

STATIC FUNCTION GetRecordSet(oEdit1)

LOCAL oWnd, oLayV, oBrw, oBtn1, aRecordSet := {} 

*...............................................................*
* Connect
*...............................................................*

cNetServer		:= oEdit1:GetText() // Server Address
nNetPort		:= 50000            // Server Port
cNetPass		:= 'secret'         // Server Password
nCompressionLevel	:= 9                // Compression Level

lConnect := netio_connect( cNetServer , nNetPort ,, ;
            cNetPass, nCompressionLevel )

IF .Not. lConnect
	hd_MsgInfo ("Can't Connect To Server!")
	RETURN NIL
ENDIF

*...............................................................*
* Retrieve Records (An empty query string retrieves all records)
*...............................................................*

aRecordset := netio_funcexec( "query_001" , "" )

*...............................................................*
* Disconnect
*...............................................................*

netio_disconnect( cNetServer , nNetPort )   

*...............................................................*
* Create Window
*...............................................................*

INIT WINDOW oWnd ;
        TITLE 'Showing: '  + ALLTRIM(STR(LEN(aRecordset))) + ;
        ' records.'

	BEGIN LAYOUT oLayV SIZE MATCH_PARENT,MATCH_PARENT
  
		BROWSE oBrw ARRAY aRecordSet ;
                SIZE MATCH_PARENT, 0 HSCROLL

		* Some cosmetics for browse...

		oBrw:nRowHeight := 40
		oBrw:nHeadHeight := 24
		oBrw:HeadBColor := "#0000CD"

		* Add columns:

		* We must specify how the columns will be filled.
			
		* o:data contains the browse array (in our case, 
                  aRecordSet).
			
		* o:nCurrent is the current row
			
		* so, we specify o:data[o:nCurrent][1] for the 
                  column 1

		* o:data[o:nCurrent][2] for the column 2 

		* and so on...

		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][1]},140,"Id",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][2]},140,"Last",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][3]},140,"First",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][4]},140,"Street",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][5]},140,"City",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][6]},140,"State",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][7]},140,"Zip",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][8]},140,"Hire Date",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][9]},140,"Married",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][10]},140,"Age",,ALIGN_CENTER+ALIGN_VCENTER ) )
		oBrw:AddColumn( HDColumn():New( {|o|o:data[o:nCurrent][11]},140,"Salary",,ALIGN_CENTER+ALIGN_VCENTER ) )

	END LAYOUT oLayV

ACTIVATE WINDOW oWnd

RETURN NIL

IV. DOWNLOAD

Download “hadroidgui_demo.apk”  From Here

V. LINKS

Alexander Kresin (HDROIDGUI author) Web Site: Click Here

Alexander Kresin on Github: Click Here

VI. BYE!

Enjoy!

Roberto.

You can discuss about this post on the HMG SourceForge forum Here

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

18 Responses to A HARBOUR ANDROID NETIO CLIENT DEMO WITH HDROIDGUI

  1. Esgici says:

    Thanks Roberto and Alexander 🙂

    Regards

    Like

  2. bpd2000 says:

    Excellent, Thank you for sharing your knowledge

    Like

  3. bpd2000 says:

    I have install .apk file on Destkop and it is working fine [I use BlueStacks to run .apk file on Desktop]

    Like

  4. hmgthinking says:

    Thatnks. Is good to know that…

    Like

  5. Esgici says:

    Thanks to info and hint 🙂

    ( I didn’t know “BlueStacks” )

    Like

  6. hmgthinking says:

    It’s an Android app player for PC, but AFAK, you need a fast PC for it.

    Like

  7. Esgici says:

    I hope using it as an Android emulator in PC; is this possible ?

    Like

  8. hmgthinking says:

    Yes. is possible. This utility do that.

    Like

  9. Esgici says:

    Thanks to clarify 🙂

    Regards

    Like

  10. Anonymous says:

    I use “BlueStacks”bsince last 4 months w/o any trouble

    Like

  11. Esgici says:

    Hi Anonymous

    Only trouble is (as Roberto noticed) it is very slow 😦

    I guess it frequently connects to internet and we don’t know for what 😦

    By the way, why you hide your name ? Does Interpol searching you :)))

    Regards and thanks to your interest

    Like

  12. Anonymous says:

    Great ! How do I ‘quit’ from the app? I made a button with action QUIT but this gives an Harbour runtime-error!

    Like

  13. Serge says:

    How can I close such app? I tried BUTTON oBtn2 ;
    TEXT “Close” ;
    SIZE MATCH_PARENT,WRAP_CONTENT ;
    ON CLICK {||QUIT}
    But this gives an error!

    Serge

    Like

  14. hmgthinking says:

    You can close the app, simply with Android’s back button.

    Like

  15. hmgthinking says:

    There is samples showing how to quit properly on HDROIDGUI samples:
    These are the links to all samples:
    https://github.com/alkresin/hdcalcul
    https://github.com/alkresin/hddemo
    https://github.com/alkresin/hddbf

    Like

  16. Jose Perez says:

    GRACIAS Sr.Roberto

    Like

  17. Anonymous says:

    How to progress hmgweb ….? , Thanks

    Like

  18. hmgthinking says:

    I recommend you, the JMG approach, since it is more flexible. You could use a standard PHP/MySql back-end or a Harbour-CGI one if you are working with dbf files.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s