Android Question How to intercept or simulate first tab key press

Discussion in 'Android Questions' started by LuigiTasca, Nov 6, 2018.

  1. LuigiTasca

    LuigiTasca Member Licensed User

    Some time ago I developed on my application a barcode scanning. I do this intercepting the chars with activity_keypress and when I receive the tab key my application search the barcode.
    It works, but I got a problem that my customer reject. The application starts to read the barcode after the first time, because it starts to read the chars after some view lost the focus because of the tab key.
    I need to read from the first scan. How can I set the "focus" on the reading on activity_keypress, at the program start? Or how can i simulate the first tab key press to remedy the problem?

    Thank you
  2. Star-Dust

    Star-Dust Expert Licensed User

    I do not know if I understood the problem well.
    But from what I understand you open the keyboard immediately after starting the App.

    I would do so maybe, but you must try it:
    Sub Activity_Create(FirstTime As Boolean)
    Dim K As IME
    End Sub
  3. Star-Dust

    Star-Dust Expert Licensed User

    I would do this to simulate the tab key at startup

    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    End Sub
  4. LuigiTasca

    LuigiTasca Member Licensed User

    I make you an example
    No, It wouldn't work.

    I make you an example:
    1. I start my activity. I don't know where focus is set (I don't need a focused view).
    2. I read a barcode with my scanner (with tab as terminator char)
    3. Application does not intercept the chars in anyway. But after that it reads the tab char is like the focus has setted like I need.
    4. From now the scans pass in the activity_keypress and I can intercept them.

    I need something that set the "focus" on the activity_keypress.
  5. Star-Dust

    Star-Dust Expert Licensed User

    Focus is an event of views, it is not a function of events.
    KeyPress is already an event of a Vista, and Focus is another event related to a view.

    Unfortunately I do not understand what you need, I can not help you. Sorry
  6. LuigiTasca

    LuigiTasca Member Licensed User

    Ciao Stardust, ho appena visto che sei italiano!
    Provo a spiegarmi meglio...
    Non riesco ad intercettare la prima lettura del barcode all'avvio del programma. Dopo la prima lettura le successive le leggo normalmente, intercettando l'evento keypress. Uso come carattere di fine lettura il tab.

    Ho lo stesso problema anche quando ho il focus su un edittext, finché non leggo il carattere tab e la view perde il focus l'evento activity_keypress non si scatena. Questo ovviamente perché l'evento viene intercettato dall'edittext. Questo non è un problema ma a parer mio è lo stesso motivo per cui non intercetto quello all'avvio.

    Non so come far perdere automaticamente il focus all'eventuale view che mi intercetta l'evento e che non ho ancora identificato.

  7. Star-Dust

    Star-Dust Expert Licensed User

    Please open the same post in the Italian forum, because English is required. So I can answer you in Italian

    With which scanner do you read the barcode? With the device's camera?
    DonManfred likes this.
  8. LuigiTasca

    LuigiTasca Member Licensed User

    No with physical scanner in keyboard emulation
  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