wi-fi connection with android lazarus / 43-Android ---------------------------------------------------------------------- Stygian · 2014-09-16 18:43 Hello Guys, I'm trying to do some network connetion with android. I use Indy which is compile well. I created a simple SMTP with it. but as you know you have to use some .dll under windows if you are try to send mails wot google. I have two questions: 1, Is this any free smtp where i don't have to use SSL? 2, If no, how I can get .so library for that? Thanks, Stygian ---------------------------------------------------------------------- taazz · 2014-09-16 18:49 you mean the open ssl library? Isn't that included in all the linux based OS including android? ---------------------------------------------------------------------- Stygian · 2014-09-16 18:54 Yes the openssl. I know that linux have that library, but how i tell my program to use them under android? I don't even know where i should search it. Is this any treeview of something from the android files? ---------------------------------------------------------------------- taazz · 2014-09-16 19:12 have you tried to simple build your application that uses it for android and see what happens? If yes what is the error message that your application is generating? I guess that since android is linux based and indy already supports linux it should simple work. Sorry I have 0 android experience it is in my to learn list though. ---------------------------------------------------------------------- Stygian · 2014-09-16 19:15 Only on AVD(It closed itself). But I'll install it. And see what happends ---------------------------------------------------------------------- Stygian · 2014-09-16 19:37 Installed it and it's froze when I push the button(Connect). ---------------------------------------------------------------------- engkin · 2014-09-16 23:40 I'm not better than Taazz. Just a few things: 1- Did you add needed permission sections to your manifest file. 2- Mention more details, like Lazarus/FPC, Android SDK/bin tools, your device, etc. 3- Posting source code encourages people to test, check and help. ---------------------------------------------------------------------- Stygian · 2014-09-17 07:06 Hello, I'm not add any files to my project, I need the openssl library I think to start this program properly. I use LaztoApk version 0.9.026 SDK version 23.0.2 The Lazarus version is 1.3 with FPC 2.7.1 My target device will be a tablet but now i test it on my Dell Steak 5(rooted bootloader open) I post the source code(btw it's working perfectly on windows): Code: [Select]unit Testmain; {$mode objfpc}{$H+} {$ifdef Linux}{$ifdef CPUARM}   {$define Android} {$endif}{$endif} interface uses   Classes,   SysUtils,   FileUtil,   Forms,   Controls,   Graphics,   Dialogs,   StdCtrls,   ExtCtrls,   StrUtils,   customdrawnint,   LCLIntf,   customdrawncontrols,   customdrawndrawers,   customdrawn_common,   lazdeviceapis,   IdSMTP,   IdSSLOpenSSL,   IdMessage,   dynlibs; type   { TfrmTestMain }   TfrmTestMain = class(TForm)     CDButton1: TCDButton;     CDButton2: TCDButton;     CDButton3: TCDButton;     CDinf: TCDStaticText;     Msg: TIdMessage;     SSL: TIdSSLIOHandlerSocketOpenSSL;     SMTP: TIdSMTP;     procedure CDButton1Click(Sender: TObject);     procedure CDButton2Click(Sender: TObject);     procedure CDButton3Click(Sender: TObject);     procedure FormCreate(Sender: TObject);   private   public   end; var   frmTestMain: TfrmTestMain; implementation {$R *.lfm} { TfrmTestMain } procedure TfrmTestMain.CDButton3Click(Sender: TObject); begin   Close; end; //this part was for only test but not worked(cause Android is not Windows) //procedure TfrmTestMain.FormCreate(Sender: TObject); //var //  L1Handle, L2Handle: TLibHandle; //begin //  L1Handle := LoadLibrary('libeay32.dll'); // L2Handle := LoadLibrary('ssleay32.dll'); //end; //this part was for only test but not worked(cause Android is not Windows) procedure TfrmTestMain.CDButton1Click(Sender: TObject); begin   SMTP.Username:= 'smtpteszt2014@gmail.com';   SMTP.Password:= '*********';   SMTP.Host:= 'smtp.gmail.com';   SMTP.Port:= 587;   SSL.Destination:= 'smtp.gmail.com:587';   if(not SMTP.Connected)then   begin     CDinf.Caption:= 'Csatlakozva a(z) smtp.gmail.com kiszolgálóhoz.';     CDButton1.Caption:= 'Disconnect';     SMTP.Connect;     SMTP.Authenticate;   end else   begin     SMTP.Disconnect;     CDinf.Caption := 'Sikeres lecsatlakozás.';     CDButton1.Caption := 'Connect';   end; end; procedure TfrmTestMain.CDButton2Click(Sender: TObject); var  mydate: string; begin   Msg.CharSet:= 'utf-8';   Msg.From.Name:= UTF8Encode('Sp0T');   Msg.From.Address:= 'smtpteszt2014@gmail.com';   Msg.ReplyTo.EMailAddresses:= 'smtpteszt2014@gmail.com';   Msg.Recipients.EMailAddresses:= mymail@gmail.com';   mydate := FormatDateTime('yyyy.mm',Now);   Msg.Subject:= UTF8Encode('Android Test Mail');   Msg.Body.Text:=UTF8Encode('Hello'+#13#10+#13#10+                             'I am a test android program.'+#13#10+                             'Please do not replay to me');   Msg.Date := Sysutils.Date;   Msg.MessageParts.Clear;   SMTP.Send(Msg); end; end. ---------------------------------------------------------------------- engkin · 2014-09-17 15:43 Did you check the logcat output? ---------------------------------------------------------------------- felipemdc · 2014-09-17 15:51 I'd try to find a Java e-mail API and call it via JNI. Here is some java code from a quick search, it should be streight forward to convert it to JNI if it doesn't require interfaces: http://stackoverflow.com/questions/2020088/sending-email-in-android- using-javamail-api-without-using-the-default-built-in-a Finding or compiling a SSL native library for Android will probably be headachish ... here is the first result in Google: http://stackoverflow.com/questions/3046573/how-to-use-openssl-library- in-the-android-application ---------------------------------------------------------------------- Stygian · 2014-09-17 16:46 I attached the logcat output. ---------------------------------------------------------------------- Stygian · 2014-09-18 12:17 @felipemdc: Okay. The base idea is wi-fi communication with another device. I made the SMTP because it's easy to do. But what if I try a simple TFTP server-client communication(no SSL and other crap). By the way can be the android version missmatch the problem? I use 4.0.3(API 15) with laztoapk and my phone version is 2.3.3(API 10). The example program is working prefectly on my phone. ---------------------------------------------------------------------- felipemdc · 2014-09-19 07:14 I don't know how the FTP implementation is done, so I don't know if it will work in Android. Libraries like Indy were ported to Linux but Android is not identical, so it can work or not work. The most guaranteed way for it to work is to call a Android Java API via JNI. ---------------------------------------------------------------------- Stygian · 2014-09-19 09:38 There is an arm-android lib in indy. Maybe I should try "Android Modul Wizard" under linux. Ant can be a good help to create JNI file.