Android Tutorial B4A-Bridge source code

mr23

Active Member
Licensed User
Erel, could you consider adding the following feature? B4A-Bridge indicates when a file transfer is in progress with 'progress'. Reason: in lower quality/bandwidth Wifi environments, it would be nice to have an indication the transfer started, and that it is making progress (ie, didn't stall/die).
Basically a packet counter is added, and with a value of -1 indicates no transfer occurring, 0 indicates started, and >0 is the packet count. Status line is updated with the value when > -1, ie, started/in-progress. When complete status returns to "Connected".
B4X:
In Service1:

Sub Process_Globals
    Dim APK_XFER_PacketCount As Int = -1

Sub HandleFileStart
    Log("Installing file.")
    APK_XFER_PacketCount = 0
    CallSubDelayed(Main, "UpdateStatus")

Sub HandleFilePacket(Buffer() As Byte)
    Try
        Out.WriteBytes(Buffer, 1, Buffer.Length - 1)
        APK_XFER_PacketCount = APK_XFER_PacketCount + 1
        CallSubDelayed(Main, "UpdateStatus")

Sub HandleFileClose
    APK_XFER_PacketCount = -1
    CallSubDelayed(Main, "UpdateStatus")

In B4a-Bridge.b4a:

Sub UpdateStatus
    If Service1.ConnectedStatus Then
        If Service1.APK_XFER_PacketCount > -1 Then
          lblStatus.Text = "File Transfer: " & Service1.APK_XFER_PacketCount
        Else
          lblStatus.Text = "Status: Connected"
        End If
I do some work near the limits of my current Wifi access point, and sometimes when I kick off an Alt-3, it never makes it to the "Install" step on the android, and the GUI sits in "Debug". Presently only an "Installing" makes it into the Log, and if the Wifi is good enough it shows in the GUI log.
You might also consider a packet number in each packet after the command byte, and a total count in the start/filename packet; then percentage could be displayed and you can detect a missed packet. However as you know that would require a B4A release, so in the future perhaps.

In the meantime I modified a copy of Bridge-B4A here.

-Chris
 

Fusseldieb

Active Member
Licensed User
I have made a modded version of the B4A Bridge.
Maybe @Erel like it and will put it on Google Play ;)

Changes:
- Tuned the design
- Added restart button (Stops and restarts the previous connection)
- Changed version from V2.10 to V2.11

I have attached the source code of the modded version (That in the "zip" archive)
And the APK for you guys to test it out :)
 

Attachments

bluejay

Active Member
Licensed User
VersionCode and VersionName under Module Attributes also need to be changed.
These are the fields that Google Play and Android Installer will look at.
 

Theera

Well-Known Member
Licensed User
Hi Erel,
The source code of B4A-Bridge could be supported for android wear,couldn't it?
 

janderkan

Active Member
Licensed User
Almost all my development is for Android devices with an RJ45 port.
It was annoying to switch between WiFi and cable all the time.
So this is a very small update to B4A Bridge that detects if you are connected using WiFi or cable.
Attached is source and apk.
Jan
 

Attachments

Last edited:

erosmax

Well-Known Member
Licensed User
I update version 2.14

Insert code of mr23 and changed the Manifest with code for insert icon into ANDROID TV.
Please insert this Manifest and the simply Activity (TVActivity) in your future update.
Thanks
 

Attachments

jsprings

Member
Licensed User
Try latest version (2.14) compile an error:

B4A version: 6.31
Parsing code. (0.01s)
Compiling code. (0.04s)
Compiling layouts code. (0.00s)
Organizing libraries. Error
Maven artifact not found: com.android.support/support-v4

Help?
 

jsprings

Member
Licensed User
Install two repositories, compile error:

B4A version: 6.31
Parsing code. (0.01s)
Compiling code. (0.05s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. Error
res\values-v20\theme.xml:3: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Material.Light'.

Next?

Thanks,

SDK install:
 

Attachments

Top