Android Question Problem with edittext.requestfocus

oniblabp

New Member
Hello everyone. First post ever here. So please be gentle.

The code i'm having trouble is this one:

cmdBuscar_Click:
Private Sub cmdBuscar_Click
    If FueraDeLinea Then
        ToastMessageShow("Fuera de Linea",False)
        MostrarControles(True)
        txtConteo.RequestFocus
        txtConteo.SelectAll
    Else
        Dim j As HttpJob
        Dim Encontrado As Boolean
        j.Initialize("j",Me)
        j.PostString("http://" & APIServer.Trim & "/api/v1/buscarproducto.php","codigo=" & txtCodigo.Text)
        j.GetRequest.SetContentType("application/x-www-form-urlencoded")
        wait for (j) JobDone(j As HttpJob)
        If j.Success Then
            Dim Leido As String
            Leido=j.GetString
            Log(Leido)
        
            If Leido.Trim.Length>0 Then
                If Leido.Contains("fail")=False Then
                    Encontrado=True
                    ToastMessageShow("Encontrado",False)
                    Dim parser As JSONParser
                    parser.Initialize(Leido)
                    Dim root As List = parser.NextArray
                    For Each colroot As Map In root
                        Dim descripcion As String = colroot.Get("descripcion")
                        Dim equivalencia As String = colroot.Get("equivalencia")
                        Dim prodid As String = colroot.Get("prodid")
                        Dim cantidad As String = colroot.Get("cantidad")
                    Next
                
                    txtProdid.Text=prodid
                    txtEquivalencia.Text=equivalencia
                    txtDescripcion.Text=descripcion
                    txtExistencia.Text=cantidad
                
                    MostrarControles(Encontrado)
                
                    txtConteo.RequestFocus
                    txtConteo.SelectAll
                Else
                    Encontrado=False
                    MostrarControles(Encontrado)
                    ToastMessageShow("No encontrado",False)
                    txtCodigo.RequestFocus
                    txtCodigo.SelectAll
                End If
            End If
        Else
            ToastMessageShow("No pude comunicarme con server API",False)
        End If
        j.Release       
    End If
End Sub


txtCodigo_EnterPressed:
Private Sub txtCodigo_EnterPressed
    cmdBuscar_Click
End Sub

IF i use the keyboard in my cellphone to enter a not existent code and press the "BUSCAR" button, it shows the ToastMessage indicating that it's offline, and it sets the focus on txtConteo properly. I can see the cursor blinking in the field whether it has a value or not.

BUT if i use a codebar reader, it reads the not existent code, shows the ToastMessage but no edit text view gets the focus. So, if i read another code inmediatly using the scanner, or if i press RETURN in the android keyboard, the app crashes. The app just closes.

I've tried changing the "code end char" on the reader, from ENTER (0x0d) to RETURN (0x0a). Same result.

The only way it works it's configuring the scanner to not sending an ENTER or RETURN. But the user is forced to press the button "BUSCAR".
With 30 codes to scan it's maybe nothing. But when there are 3000 codes to scan, it's not functional.

If anyone could shed a light on this issue, i would appreciate it.

Thanks in advance and BTW, what an excellent language is B4A. I'm loving it so far.
 

oniblabp

New Member
OK, so far i found that the focus goes to my Exit Button. So when i scan again with the barcode scanner, it hits enter and the app ends.
So the problem is that txtConteo.requestfocus is not working when the barcode scanner triggers.

The problem continues....
 
Upvote 0

oniblabp

New Member
This is what happens when i scan the code.

LOG:
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
MSG_RESIZED: frame=[0,0][720,1280] ci=[0,0][0,0] vi=[0,0][0,503] or=1
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
The input has been finished in ImeInputStage.
ViewPostIme key 0
prepareNavigationBarInfo() DecorView@bec443f[main]
getNavigationBarColor() -855310
Starting input: tba=fmkt.inventario ic=com.android.internal.widget.EditableInputConnection@5ab9026 mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
Input channel constructed: fd=67
Input channel destroyed: fd=66
clearMetaKeyStates on inactive InputConnection
beginBatchEdit on inactive InputConnection
setComposingText on inactive InputConnection
endBatchEdit on inactive InputConnection
beginBatchEdit on inactive InputConnection
setComposingRegion on inactive InputConnection
endBatchEdit on inactive InputConnection
clearMetaKeyStates on inactive InputConnection
Input channel constructed: fd=66
setView = android.widget.LinearLayout{83088b2 V.E...... ......I. 0,0-0,0} TM=false MM=false
Text: Guer in android.widget.Toast$TN@1fca003
Flattened final assist data: 5212 bytes, containing 1 windows, 21 views
Relayout returned: old=[0,48][720,1280] new=[220,561][500,649] result=0x6 surface={true 3431350272} changed=true
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000,  [280x88]-format:1
eglCreateWindowSurface = 0xe2110b20, 0xcc864008
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
MSG_RESIZED: frame=[220,561][500,649] ci=[0,0][0,0] vi=[0,0][0,0] or=1
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
uid=10435(fmkt.inventario) identical 2 lines
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
ViewPostIme key 1
prepareNavigationBarInfo() DecorView@bec443f[main]
getNavigationBarColor() -855310
Starting input: tba=fmkt.inventario ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
Input channel constructed: fd=83
Input channel destroyed: fd=67
MSG_RESIZED: frame=[0,0][720,1280] ci=[0,0][0,0] vi=[0,0][0,432] or=1
EGLNativeWindowType 0xcc864008 disconnect failed
eglDestroySurface = 0xe2110b20, 0xcc864000
dispatchDetachedFromWindow
Input channel destroyed: fd=66
 
Upvote 0
Top