RTC Forums
April 26, 2024, 02:35:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: 1 [2]
  Print  
Author Topic: Delphi XE5 Android Support  (Read 14874 times)
jimwang
Newbie
*
Posts: 8


« Reply #15 on: October 23, 2013, 06:00:46 PM »

On the server, I used RtcHttpServer, Port 80, Adding FuncGroup, Module, Function components as the demo. Function to serve time. FileName is /TEST, Function is TIME
At the client (Both Windows and Android clients), I use the RtcHttpClient and ClientModule. It is over WIFI LAN, on actual HTC device not on simulator or mobile connection. IP address 192.160.0.235. The router is configured correctly. I wrote a similar simple Indy IdTcpServer-Client demo, and it works on HTC. And I've tried FixupRequest.RemovePrevix, true and false. Tried both fmt_RTC and fmt_XMLRPC.

During debug (of the HTC client), when call client's "Execute", it shows an exception "connection problem". Could be something I did wrong, that I don't know off. The exactly same client code wrote in Windows works.

Is there an android working demo I can try out and trace?

Thanks Danijel

Jim
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #16 on: October 23, 2013, 07:09:22 PM »

All Projects from the SDKDemos_FMX2 Project Group should work with Delphi XE5 on Android devices.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #17 on: October 23, 2013, 07:23:03 PM »

To simplify debugging, set the "Blocking" property on RtcHttpClient component to TRUE and make sure the MultiThreaded property is FALSE.

Best Regards,
Danijel Tkalcec
Logged
jimwang
Newbie
*
Posts: 8


« Reply #18 on: October 23, 2013, 08:23:46 PM »

Nope, Danijel,

I compiled both the fmx2AppServer and Client, works on Windows. And further created an Android App, copy all components, code, events, etc to the Android device. Made sure all the events are linked and components are set as good. Pointing to the running frm2AppServer at 192.168.0.235, port 8080 as usual. Somehow still doesn't work. Cannot connect. Tried client in blocking mode with multi-tasking too. Any idea?

Thanks,

Jim
Logged
jimwang
Newbie
*
Posts: 8


« Reply #19 on: October 23, 2013, 08:43:36 PM »

And I run windows version fmx2AppClient on other PC over the network, works too. So it's not the server or network side for sure.

Thanks,
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #20 on: October 23, 2013, 09:00:35 PM »

Well ... these same Projects worked on my Kindle Fire HD (Android device), and (as you can see) other developers have reported that they got their Project(s) working on Android too, so I can not say why it does not work on yours.

You've said that you are using Port 8080 on the Server. Have you tried using Port 80?

Have you tried running the File_Client Project (also in the SDKDemos_FMX2 group) without modifications and send requests to Web Servers over the Internet? With that Demo, you should not have to make any changes. Just build it, deploy it to your Android device and click "POST".

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #21 on: October 23, 2013, 09:40:09 PM »

Are you using "Build" before you deploy the Project to the Android device? If you use "Compile", Delphi will be using old DCU files and these won't work. You need to use "Build" every time when working on multiple platforms, to ensure that all the files will be recompiled.

Best Regards,
Danijel Tkalcec
Logged
jimwang
Newbie
*
Posts: 8


« Reply #22 on: October 23, 2013, 10:40:21 PM »

Thanks Danijel for the prompt responses,

I did "build", "build all", and I tried 80 before move to 8080. What I did was to use the RawTcpServer and Client components. Write('Time'), Write(TimeToStr(Now()), etc...

It works on Windows, but not on Android phone. I did receive "OnConnect" event though, but when I shutdown the server, did not see disconnect or error even firing up.
When call sender.Write('Time'); the server never see the message.

I know and see other developers got it working, but could not figure out what is it I am not doing or did wrong. I will try the fileserver demo later on.

Thanks,

Jim
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #23 on: October 23, 2013, 11:55:12 PM »

TRtcTcpClient and TRtcTcpServer components require special handling to work on non-Windows platforms. You need to manually call "NeedMoreData" to signal the components when to start reading from the socket. Without that, you will never receive anything. But the fact that you did get the OnConnect event is a good sign, because it means the physical connection is working.

Have you tried using the File_Client FMX2 Demo Project from your Android device? Or ... did you try to create a very simple Client Project by following the Quick Start Client Lesson 1 and try accessing the index page of some Web Server on the Internet?

Have you tried running the same code on the Android simulator?

Is there any difference when running it with, or without a Debugger?

If you can not get it working by trial and error, the only thing I can suggest is to go into the code step-by-step as it executes and see where it stops working. Setting RtcHttpClient components Blocking property to True and MultiThreaded to False should eliminate the problem of switching between multiple threads, so you should be able to follow the code as it executed. You won't see exceptions raised if the problem is related to low-level APIs, but should get an error code from the low-level API, if there is a problem with the socket.

Best Regards,
Danijel Tkalcec
Logged
jimwang
Newbie
*
Posts: 8


« Reply #24 on: October 24, 2013, 03:57:02 AM »

Interesting enough. When I run the fmx2AppClient, when making connection and disconnections, fmx2AppServer see it. But when run flood test, nothing happens.

Thanks for the help, Danijel. I will run some more debugging tomorrow.

Jim
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #25 on: October 24, 2013, 10:53:08 AM »

I've ran more different tests with Delphi XE5 Projects running on my Android Tablet and bumped into some problems with Access Violations, after which things just stopped working properly.

What I've found out so far, is that changing lines 130 and 132 in the "rtcTypes.pas" unit (Lib folder) to declare RtcIntPtr and RtcThrID types as NativeUInt for CPUARM instead of longword seems to have a positive effect for Android Apps (I did not get Access Violations in my tests after making these two changes) ...

{$ELSE}{$IFDEF CPUARM}
  // @exclude
  RtcIntPtr = NativeUInt;
  // Thread ID
  RtcThrID = NativeUInt;
{$ELSE}{$IFDEF FPC}

... but, since the nature of memory related problems is such that everything could be working without a single visible problem most of the time, but then things could just stop working for no apparent reason (or the App would start raising Access Violations at seemingly random ocasions), I can not say if that small change will have solved all possible issues with the new Mobile compiler in Delphi XE5.

Best Regards,
Danijel Tkalcec
Logged
jimwang
Newbie
*
Posts: 8


« Reply #26 on: October 25, 2013, 05:30:57 AM »

Works now! Turn AutoConnect On, and Connect first. Thanks Danijel.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #27 on: October 25, 2013, 09:34:51 AM »

Thanks for your feedback. I have released RTC SDK v6.24 (2013.Q3) now with the above changes applied to the rtcTypes.pas unit, so anyone who is reading this post only has to download the latest RTC SDK release to fix RTC-related AVs in Android Apps.

Best Regards,
Danijel Tkalcec
Logged
jimwang
Newbie
*
Posts: 8


« Reply #28 on: October 26, 2013, 06:33:17 AM »

Thanks Danijel,

Having it working, I just bought a Samsumg mega, installed the test app. Works!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #29 on: October 26, 2013, 08:27:35 AM »

Thank you for the feedback.

Should you encounter any problems, please let me know.

Best Regards,
Danijel Tkalcec
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.028 seconds with 16 queries.