Android Tutorial B4A-Bridge source code

Discussion in 'Tutorials & Examples' started by Erel, Mar 8, 2011.

  1. mr23

    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".
    Code:
    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
     
  2. mr23

    mr23 Active Member Licensed User

    Erel, what port number does the Designer activity use ?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    5000 or 5117
     
  4. Fusseldieb

    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 :)
     

    Attached Files:

    Theera and Erel like this.
  5. bluejay

    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.
     
  6. mr23

    mr23 Active Member Licensed User

    Erel, will you be updating this thread with the latest source changes?
     
    Theera likes this.
  7. Theera

    Theera Well-Known Member Licensed User

    Hi Erel,
    The source code of B4A-Bridge could be supported for android wear,couldn't it?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Yes.

    V2.12 is attached.
     

    Attached Files:

    Last edited: Dec 14, 2014
  9. klaus

    klaus Expert Licensed User

    Isn't the last B4A-Bridge version 2.12 ?
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Yes. It was a typo.
     
  11. janderkan

    janderkan 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
     

    Attached Files:

    Last edited: Sep 13, 2015
    Ed Brown likes this.
  12. AscySoft

    AscySoft Active Member Licensed User

    I updated to version 2.13 via Google Play. Is there somehow the source code of this version anywhere on the forum?
     
    Last edited: Jan 6, 2016
  13. Erel

    Erel Administrator Staff Member Licensed User

    I've uploaded it to the first post.
     
  14. AscySoft

    AscySoft Active Member Licensed User

    Thanks alot!
     
  15. erosmax

    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
     

    Attached Files:

  16. AscySoft

    AscySoft Active Member Licensed User

    Hi Erel. Is there available the source code of the latest version? (2.14 official)
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    I've uploaded the latest version to the first post.
     
    AscySoft likes this.
  18. jsprings

    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?
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. jsprings

    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:
     

    Attached Files:

Loading...