Hello great community!,
I have errors by sending video files over WLAN.
Error Function:
Yes i Know "GetPathFromContentResult" is not the best.
and here is the error line:
And the last but not the least, the full error log:
Thanks for helping me
greetings.
I have errors by sending video files over WLAN.
Error Function:
B4X:
Sub GetPathFromContentResult(UriString As String) As String
If UriString.StartsWith("/") Then Return UriString 'If the user used a file manager to choose the image
Dim Cursor1 As Cursor
Dim Uri1 As Uri
Dim Proj() As String = Array As String("_data")
Dim cr As ContentResolver
cr.Initialize("")
If UriString.StartsWith("content://com.android.providers.media.documents") Then
Dim i As Int = UriString.IndexOf("%3A")
Dim id As String = UriString.SubString(i + 3)
Uri1.Parse("content://media/external/images/media")
Cursor1 = cr.Query(Uri1, Proj, "_id = ?", Array As String(id), "")
Else
Uri1.Parse(UriString)
Cursor1 = cr.Query(Uri1, Proj, "", Null, "")
End If
Cursor1.Position = 0
Dim res As String
res = Cursor1.GetString("_data")
Cursor1.Close
Return res
End Sub
Yes i Know "GetPathFromContentResult" is not the best.
and here is the error line:
B4X:
res = Cursor1.GetString("_data")
And the last but not the least, the full error log:
B4X:
Installing file.
PackageAdded: package:b4a.WireSharing
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (wiresharing) Create **
** Service (wiresharing) 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_getpathfromcontentresult (B4A line: 277)
res = Cursor1.GetString("_data")
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
at android.database.CursorWrapper.getString(CursorWrapper.java:137)
at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
at b4a.WireSharing.main._getpathfromcontentresult(main.java:927)
at b4a.WireSharing.main._cc_result(main.java:812)
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.WireSharing.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)
Thanks for helping me
greetings.