Android Question Wait For error

Status
Not open for further replies.

Almora

Well-Known Member
Licensed User
Longtime User
B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean

    Log("Error: " & MEDIA_ERROR)
    
    Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
    
    For Each v As View In Activity.GetAllViewsRecursive
        If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
            Dim x As B4XLoadingIndicator = v.Tag
            x.Hide
        End If
    Next
    
    Activity.Finish
    StartActivity(main)
    
    Return True
    
End Sub


Resumable subs return type must be ResumableSub (or none).

I get this error.
what should I do..
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
You should make the return type of the sub ResumableSub. (Btw, the error has nothing to do with MsgboxAsync) :)

B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As ResumableSub

    Log("Error: " & MEDIA_ERROR)
   
    Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
   
    For Each v As View In Activity.GetAllViewsRecursive
        If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
            Dim x As B4XLoadingIndicator = v.Tag
            x.Hide
        End If
    Next
   
    Activity.Finish
    StartActivity(main)
   
    Return True
   
End Sub

https://www.b4x.com/android/forum/threads/b4x-resumable-subs-that-return-values-resumablesub.82670/

- Colin.
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I read this topic.
how to apply. I could not.
Would you give an example?...
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I read this topic.
how to apply. I could not.
Would you give an example?...
I did give an example in my reply. I changed the sub return type from Boolean to ResumableSub. Does that not work?

- Colin.
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I've tried
not working.



Error: 1
java.lang.ClassCastException: anywheresoftware.b4a.keywords.Common$ResumableSubWrapper cannot be cast to java.lang.Boolean
at com.tillekesoft.vitamio5.VideoView$3.onError(VideoView.java:332)
at io.vov.vitamio.widget.VideoView$5.onError(VideoView.java:223)
at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1765)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
You need to change your call to something like:
B4X:
Wait for (vvvit5_Error(errorCode)) Complete (ret As Boolean)

- Colin.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
Ek Açıklama 2020-02-09 094802.jpg




B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean
'...
End Sub

wait for .... error when adding

Resumable subs return type must be ResumableSub (or none).
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
Thank you for your help.
but
I couldn't do it with the method you specified.

such a method works. The message is waiting for user confirmation and does not give an error.



B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean

    Log("Error: " & MEDIA_ERROR)
    
    videowait
    
    For Each v As View In Activity.GetAllViewsRecursive
        If v.Tag Is B4XLoadingIndicator And v.Visible = True Then
            Dim x As B4XLoadingIndicator = v.Tag
            x.Hide
        End If
    Next
      
    Return True
    
End Sub



Sub videowait

    Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
    Activity.Finish
    StartActivity(main)

End Sub
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Thank you for your help.
but
I couldn't do it with the method you specified.

Well I don't know what you were doing, but the code below works as expected. The vvvit5_Error sub is called, the msgbox is displayed & waits for input, then when the OK button is tapped, the vvvit_Error sub resumes, then returns to the line after the original call in Activity_Resume:
B4X:
Sub Activity_Resume
    Wait for (vvvit5_Error(1)) Complete (ret As Boolean)
    Log("Returned from vvvit5_Error")
End Sub

Sub vvvit5_Error(MEDIA_ERROR As Int) As ResumableSub

    Private xui As XUI
    Log("Error: " & MEDIA_ERROR)
   
    Log("Waiting for MsgboxAsync result")
    Wait For (xui.MsgboxAsync("error","info")) Msgbox_Result (Result As Int)
    
    Log("Finished waiting for MsgboxAsync result")  
    Return True
   
End Sub

- Colin.
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I tried your code.
gives this error.



Error: 1
Waiting for MsgboxAsync result
java.lang.ClassCastException: anywheresoftware.b4a.keywords.Common$ResumableSubWrapper cannot be cast to java.lang.Boolean
at com.tillekesoft.vitamio5.VideoView$3.onError(VideoView.java:332)
at io.vov.vitamio.widget.VideoView$5.onError(VideoView.java:223)
at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1765)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)


B4X:
Sub vvvit5_Error(MEDIA_ERROR As Int) As Boolean
'...
End Sub

I think this has to be ..
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Status
Not open for further replies.
Top