Android Question Error by sending a picture via WIFI

Alexander Stolte

Expert
Licensed User
Longtime User
Hi,

i become these Errors by debug:

B4X:
LogCat connected to: B4A-Bridge: samsung SM-G935F
--------- beginning of main
Installing file.
PackageAdded: package:b4a.example.filetransfer
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (filetranser) Create **
** Service (filetranser) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (CallSubDelayed - UpdateStatus)
running waiting messages (3)
** Activity (main) Resume **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
--------- beginning of system
PackageAdded: package:b4a.example.filetransfer
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (filetranser) Create **
** Service (filetranser) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example.filetransfer
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (filetranser) Create **
** Service (filetranser) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
StartAStream
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
main_cc_result (B4A line: 213)
If File.Exists("", normalizedFile) == False Then
java.lang.NullPointerException: name == null
    at java.io.File.<init>(File.java:146)
    at anywheresoftware.b4a.objects.streams.File.Exists(File.java:91)
    at b4a.example.filetransfer.main._cc_result(main.java:799)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.phone.Phone$ContentChooser$1.ResultArrived(Phone.java:843)
    at anywheresoftware.b4a.BA$4.run(BA.java:513)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:398)
    at b4a.example.filetransfer.main$ResumeMessage.run(main.java:300)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I m using the code from the Project: File Transfer

https://www.b4x.com/android/forum/t...nd-and-receive-files-with-asyncstreams.30493/

How can i fix then?

The Error comes on this Sub ,in: If File.Exists("", normalizedFile) == False Then


B4X:
Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Dim normalizedFile As String = GetPathFromContentResult(FileName)
        If File.Exists("", normalizedFile) == False Then
            ToastMessageShow("File is not accessible.", True)
            Return
        End If
        CallSubDelayed3(FileTranser, "SendFile", "", normalizedFile)
    Else
        If LastException.IsInitialized Then ToastMessageShow(LastException.Message, True)
    End If
End Sub
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
I have a Problem by "Read the file into an array of bytes"

I use this code:

B4X:
Sub BytesToFile (Dir As String, FileName As String, Data() As Byte)
    Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
End Sub

B4X:
Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Dim normalizedFile As String = BytesToFile(FileName)
        If File.Exists("", normalizedFile) == False Then
            ToastMessageShow("File is not accessible.", True)
            Return
        End If
        CallSubDelayed3(WireSharing, "SendFile", "", normalizedFile)
    Else
        If LastException.IsInitialized Then ToastMessageShow(LastException.Message, True)
    End If
End Sub

By: BytesToFile(Dir, FileName, Data)

What is "dir" and "data" ?
 
Upvote 0
Top