Android Question How to use FTP, FTPS and SFTP combined in the same activity

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I have a question that I don't know how to solve.
I have an application that sends/receives files via FTP, using the Net library. No problem with FTP or FTPS.
Now I want to add that it can send/receive via SFTP, so I use the Fsch library, it works fine too.

But, I have to duplicate the code, one activity for Net and another activity for Jsch.
Is there any way to do something like the following?

B4X:
If bUseFtp Or bUseFtps Then
  Dim myFtp As Ftp
Else
  Dim myFtp As Sftp
End If

Thank you.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Communication code shouldn't go in activities as activities can be paused.

Either move the communication code to the starter service or, better, switch to B4XPages which solves all these issues.

Is there any way to do something like the following?
No. You can create classes for each type of communication with the same interface and then call them with CallSub.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thank you for the information, I will consider the advice šŸ‘
I can't change this project to B4Xpages because it's the first one I did, in 2012, and it's quite "muddy".
 
Upvote 0
Top