Android Question Check if 'ToastMessageShow' is visible

Discussion in 'Android Questions' started by AndyUK, Mar 21, 2019.

  1. AndyUK

    AndyUK Member Licensed User

    Hi

    I have a problem when my Bluetooth app is initialising in that if a button is pushed it locks up the communication with Bluetooth controller. Is there a way to check when a specific ToastMessageShow is being displayed, then notify when message has cleared?

    Andrew
     
  2. DonManfred

    DonManfred Expert Licensed User

    I don´t think there is anything about it. You can not read toast-message-content as far as i know.
     
  3. AndyUK

    AndyUK Member Licensed User

    Is it possible to check if any ToastMessage is being displayed so I can disable all buttons? Even if its only when the initial display appears so I could start a timer.
     
  4. DonManfred

    DonManfred Expert Licensed User

    I don´t know anything about
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Sub ShowToastMessage(Msg As String)
     Button1.Enabled = 
    False
     
    ToastMessageShow(Msg, True)
     Sleep(
    7000'long message duration
     Button1.Enabled = True
    End Sub
    This code will work if you only show a single toast message. If this is not the case then you need to add:
    Code:
    Sub ShowToastMessage(Msg As String)
     ToastIndex = ToastIndex + 
    1 'global int variable
     Dim MyIndex As Int = ToastIndex
     Button1.Enabled = 
    False
     
    ToastMessageShow(Msg, True)
     Sleep(
    7000'long message duration
     If ToastIndex <> MyIndex Then Return
     Button1.Enabled = 
    True
    End Sub
     
    AndyUK and DonManfred like this.
  6. AndyUK

    AndyUK Member Licensed User

    Thanks Erel that works fine.

    I have also tried to disable a panel which contains 5 buttons which does work except I cannot then enable it again after the delay, any more suggestions please. Also I want to disable a label but all the normal code does not work.

    Code:
    Sub ShowToastMessage(Msg As String)
        ToastIndex = ToastIndex + 
    1 'global int variable
        Dim MyIndex As Int = ToastIndex
        pnl_tank.Initialize(
    False)
        lbl_hh.Enabled = 
    False
        lbl_mm.Enabled = 
    False
        btn_mode.Enabled = 
    False
    '    pnl_tank.Enabled = False
        ToastMessageShow(Msg, True)
        Sleep(
    6000'long message duration
        If ToastIndex <> MyIndex Then Return
        pnl_tank.Initialize(
    True)
        lbl_hh.Enabled = 
    True
        lbl_mm.Enabled = 
    True
        btn_mode.Enabled = 
    True
    '    pnl_tank.Enabled = True
    End Sub
     
  7. DonManfred

    DonManfred Expert Licensed User

    Why are you INITIALIZEing the Panel in the sub?
     
  8. AndyUK

    AndyUK Member Licensed User

    I thought that when set to 'false' it would disable it, I have now found correct way to stop the panel being displayed so thanks for everybody's help.

    Andrew
     
  9. DonManfred

    DonManfred Expert Licensed User

    What about .Visible or .Enable?
     
  10. AndyUK

    AndyUK Member Licensed User

    The code I have added for the panel stops it being shown and works. The 2 labels are not working and yes I have tried both, but .enable = false still lets the label to be selected.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice