Android Question ASyncstream - Ignoring event (too many queued events: astreams_newdata)

Discussion in 'Android Questions' started by Husain Ragib, Apr 1, 2018.

  1. Husain Ragib

    Husain Ragib Member Licensed User

    Hi,

    I am building an application which connects to a bluetooth device via serial port and sends command and gets responses. I have created a starter service to manage the connection to the device through the Serial Class, so when the user starts the app, the first activity shows a list of paired devices and allows it to connect by clicking on one of them.

    After this I display the menu which allows the user to choose what he wants to do and based on his selection I start another activity for the specific UI task. In this activity I initialize the AStream by calling

    If AStreams.IsInitialized = False Then
    AStreams.Initialize(Starter.BTConnection.InputStream, Starter.BTConnection.OutputStream, "AStreams")
    End If

    When I send some commands to the bluetooth device sometimes I get response but sometimes the log shows

    sending message to waiting queue (astreams_newdata)
    Ignoring event (too many queued events: astreams_newdata)

    The AStream object is created in Process_Globals and AStreams_NewData and other events are defined in the activity from which it is called.

    My question is: Since the AStream object is in the same activity why does it get queued? The same operation works fine if I use the Serial class in the same activity instead of Starter Service and if it is a single activity application.

    Can you suggest what could be wrong?

    Thanks!
     
  2. Husain Ragib

    Husain Ragib Member Licensed User

    Oh I figured, I was declaring the AStreams object in Process_Globals of the activity. I moved it to Starter service and it is working as expected now.

    :p
     
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