Hi again
I'll explain my video gallery problem
I've two buttons one for "Images Browse" and other for "Videos Browse" , both of them open the gallery.
The problem, when I use my app on Sony Z Ultra (5.0.2) , and browse for videos or images will open "Recent List" , if I browse for images and choose one from that list, will work normally , But if I browse for videos and select one from that list(Recent), will not working ,
But if chose video first from the left list then chose the video will work normally..
this problem just on Sony Z Ultra , but on my Note 4 (6.0.1) , both work normally.
- is there a way to let the video on Z Ultra open directly to video list not to recent list ?
- I need the path because I want to upload the image/video.
the error here :
And i tried this code , instead of the above (but same problem)
Thank you ...
I'll explain my video gallery problem
I've two buttons one for "Images Browse" and other for "Videos Browse" , both of them open the gallery.
The problem, when I use my app on Sony Z Ultra (5.0.2) , and browse for videos or images will open "Recent List" , if I browse for images and choose one from that list, will work normally , But if I browse for videos and select one from that list(Recent), will not working ,
But if chose video first from the left list then chose the video will work normally..
this problem just on Sony Z Ultra , but on my Note 4 (6.0.1) , both work normally.
- is there a way to let the video on Z Ultra open directly to video list not to recent list ?
- I need the path because I want to upload the image/video.
B4X:
Sub Button3_Click
imageIndex = 0
Chooser.Show("video/*", "Select a video")
End Sub
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
If Cursor1.RowCount > 0 Then
res = Cursor1.GetString("_data")
End If
Cursor1.Close
Return res
End Sub
Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
Dim words() As String = Regex.Split("\/", GetPathFromContentResult(FileName))
Dim name As String = words(words.Length-1)
Dim path As String
Dim i As Int
For i = 0 To words.Length-2
path = path & words(i) & "/"
Next
Else
ToastMessageShow("Nothing Selectd", True)
End If
End Sub
the error here :
B4X:
' Cursor1.RowCount = 0
And i tried this code , instead of the above (but same problem)
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 Proj() As String
Proj = Array As String("_data")
Dim Cursor As Cursor
Dim r As Reflector
Dim Uri As Object
Uri = r.RunStaticMethod("android.net.Uri", "parse", _
Array As Object(UriString), _
Array As String("java.lang.String"))
r.Target = r.GetContext
r.Target = r.RunMethod("getContentResolver")
Cursor = r.RunMethod4("query", _
Array As Object(Uri, Proj, Null, Null, Null), _
Array As String("android.net.Uri", _
"[Ljava.lang.String;", "java.lang.String", _
"[Ljava.lang.String;", "java.lang.String"))
Cursor.Position = 0
Dim res As String
res = Cursor.GetString("_data")
Cursor.Close
Return res
End Sub
Thank you ...