B4A Tutorial [B4X] Resumable subs that return values (ResumableSub) - Erel    Aug 25, 2020   (38 reactions)   tags: wait, Comm, Code, B4X, Dialog ResumableSub, Wait For wait for the resumable sub to complete then return Null from the resumable sub and set the type in...Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to... Sub Output: after sum 3 This is the reason why it is not possible to simply return a value. Solution Resumable subs can return a new type named ResumableSub. Other subs can use this value to wait for the sub to complete and get the desired return value. Sub Button1_Click Wait For(Sum(1, 2... B4A Code Snippet Get the path to media files returned from ContentChooser - Erel    Jul 24, 2022   (8 reactions)   tags: Adjuntar un File It is a mistake to try to get a file path from the returned resource. It will not work in most... files SubName: GetPathFromContentResult Description: Content providers such as the media gallery... GetPathFromContentResult(UriString As String) As String If UriString.StartsWith("/") Then Return UriString... As String res = Cursor1.GetString("_data") Cursor1.Close Return res End Sub In... assume that the resource returned from ContentChooser comes from the file system and if... B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For - Erel    Feb 22, 2018   (49 reactions)   tags: Reference, Comm, download, Resumable Subs, Code, Wait For , the current sub is paused. This is equivalent to calling Return. Wait for a resumable sub to complete and return values from a resumable sub: https://www.b4x.com/android/forum/threads/b4x-resumable-subs-that-return-values-resumablesub.82670/ Notes & Tips - Resumable subs cannot return a value... of the code and move them to other subs that are called from the resumable sub.) - Wait For events handlers...New video tutorial: 255570732 Resumable subs is a new feature added in B4J v5.50 / B4i v4.00... B4A Code Snippet [B4X] Bytes To File - Erel    May 24, 2020   (19 reactions)   tags: Image, Share Images, Bytes, B4X, B4X Bytes To File, , bitmap to byte and revert This code is no longer needed. Use File.WriteBytes / ReadBytes.
Write an array of bytes to a file and read a file into an array of bytes.
Sub BytesToFile (Dir As String, FileName As String, Data..., 0, Data.Length)
out.Close
End Sub
Sub FileToBytes (Dir As String, FileName As String) As Byte()
Return Bit.InputStreamToBytes(File.OpenInput(Dir, FileName))
End Sub
Note that you can convert... B4A Code Snippet [B4X] HexToColor and ColorToHex - Erel    Feb 24, 2020   (17 reactions) Converts hex color strings to a color int value and vice versa: Private Sub ColorToHex(clr As Int) As String Dim bc As ByteConverter Return bc.HexFromBytes(bc.IntsToBytes(Array As Int(clr))) End Sub Private Sub HexToColor(Hex As String) As Int Dim bc As ByteConverter If Hex...) Then Hex = Hex.SubString(2) End If Dim ints() As Int = bc.IntsFromBytes(bc.HexToBytes(Hex)) Return ints(0) End Sub Depends on: B4A / B4J - ByteConverter, B4i - iRandomAccessFile... B4J Code Snippet Resumable Subs (wait for / sleep) in server handlers - Erel    Feb 16, 2020   (15 reactions) a page and returns it as the response: Sub Handle(req As ServletRequest, resp As ServletResponse) Download(resp) StartMessageLoop '<--- End Sub Sub Download (resp As ServletResponse...Resumable subs can only work when there is a message queue. By default, server handlers end when the Handle sub is completed. They do not create a message loop. If you want to wait for an event then... j.Release StopMessageLoop '<---- End Sub The Handle sub cannot be a resumable sub... B4A Tutorial Intent Filters - Intercepting SMS messages in the background - Erel    Jan 13, 2023   (15 reactions) 'Parses an SMS intent and returns an array of messages Sub ParseSmsIntent (in As Intent) As Message...") Next End If Return messages End Sub Update 2018: Static intent filters will cause... SmsInterceptor objects from the Phone library also use dynamic registration to listen for common intents.... This will prevent the process from being killed. However this will also add an ongoing notification... the intent action. If it fits then the messages will be parsed from the intent. This is done with the help... Bug? For Each Loop - Erel (first post)    Mar 14, 2021   (3 reactions) Returning an array of strings from a sub is not supported. The compiler should have thrown an error. It will be fixed. Only primitives (numbers), strings and arrays of primitives can be returned from a sub.... B4J Question I'm confused by CallSub... - Erel (first post)    Jul 29, 2019 The return is an array of byte arrays, which appears to be passed by value,
When you return an array from a sub it is not copied. You return a reference to the same array (the reference is passed by value but it is less important).
I don't see any problem with your code, assuming that the indirect calling is indeed required.... B4i Tutorial Share data from your app with ActivityViewController - Erel    Aug 26, 2021   (20 reactions)   tags: share Button :", Array(File.Combine(Dir, FileName))) Return no End Sub Sub avc_Complete (Success...50146 ActivityViewController allows the user to share data from your app using the standard share... with one or more items that you want to share and call show: Sub Page1_Click Dim avc As ActivityViewController avc.Initialize("avc", Array("Some text to share together with an image...: ${ActivityType}"$) End Sub You can also share files with ActivityViewController. Sub Page1_Click Dim... Page: 1   2   3   4   5   6   7   |