Android Question How to sign Android app with system signature? [Web server]

rtek1000

Active Member
Licensed User
Longtime User
Hi,

I would like make a server socket at 80 port, but I have not access:

B4X:
#Region  Project Attributes
    #ApplicationLabel: Webserver
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Dim AStreams As AsyncStreams
    Dim Server As ServerSocket
    Dim Socket1 As Socket
End Sub
Sub Globals
    Dim EditText1 As EditText
    Private EditText2 As EditText
    Private EditText3 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
   
    If FirstTime Then
        Server.Initialize(80, "Server")
        'Server.Initialize(5500, "Server")
        Server.Listen
        Log("MyIp = " & Server.GetMyIP)
        EditText3.Text = "My Ip:Port = " & Server.GetMyIP & ":5500"
    End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)
    If UserClosed Then
        Log("closing")
        AStreams.Close
        Socket1.Close
    End If
End Sub

Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
    If Successful Then
        ToastMessageShow("Connected", False)
        Socket1 = NewSocket
         'Can only use prefix mode if both sides of the connection implement the prefix protocol!!!
        'AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
        AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
    Else
        ToastMessageShow(LastException.Message, True)
    End If
    Server.Listen
End Sub

Sub AStreams_NewData (Buffer() As Byte)
    Dim msg As String
    msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
   
    EditText2.Text = msg
    Log(msg)
   
    Dim strHTML As String
             
    strHTML = "HTTP/1.1 200 OK"  & CRLF & _
              "Content-Type: text/html" & CRLF & _
              "Connection: close"  & CRLF & _
              "Refresh: 10" & CRLF & CRLF & _
              "<!DOCTYPE HTML>"  & CRLF & _
              "<HTML>" & CRLF & _
              "<BODY>" & CRLF & _
              "Date: " & _
              DateTime.Date(DateTime.Now) & _
              " & Time: " & _
              DateTime.Time(DateTime.Now) & _
              "<br />" & CRLF & _
              "</BODY>" & CRLF & _
              "</HTML>" & CRLF
   
    Log(strHTML)
   
    Dim Buffer() As Byte
    Buffer = strHTML.GetBytes("UTF8")
    AStreams.Write(Buffer)
   
    Do While(AStreams.OutputQueueSize > 0)
       
    Loop
   
    AStreams.Close
    Socket1.Close
End Sub

Sub AStreams_Error
    ToastMessageShow(LastException.Message, True)
    Log("AStreams_Error")
End Sub

Sub AStreams_Terminated
    Log("AStreams_Terminated")

End Sub


I found this way to sing for Eclipse App (explain below).

How do this for B4A App?


Source
 

Attachments

  • Web server.zip
    8.4 KB · Views: 291

rtek1000

Active Member
Licensed User
Longtime User
All right, I found this explanation:

Source

And this tip (I did this using FX explorer, but it did not work):

But I found a simple alternative for this case:

"Configure your router to forward port 80 to port 8080" (8080 or other port your app uses)
Source

Thank you.
 
Upvote 0