Sub thread2_start
Dim args(0) As Object
If TestRunningTime.Running Then
TestRunningTime.Interrupt
End If
If TestRunningTime.IsInitialized Then
TestRunningTimeLock.Initialize(True)
TestRunningTime.Name = "B4A Thread 2"
TestRunningTime.Start(Null,"thread2Start", args)
End If
End Sub
Sub thread2Start
Dim args(0) As Object
Do While SubDown
Log("thread2Start")
TestRunningTime.Sleep(2000)
Loop
' TestRunningTime.RunOnGuiThread("Update2",args)
End Sub
get USB dev:
Sub SelectedDevice
For i=0 To UsbManager.GetDevices.Length-1
Dim dev As UsbDevice=UsbManager.GetDevices(i)
If dev.VendorId=6790 And dev.ProductId=29987 Then
If UsbManager.HasPermission(dev) = False Then
Debug.DebugLog(Debug.LogTypes.System,"HasPermission")
UsbManager.RequestPermission(dev)
End If
If Uusbdev.IsInitialized And Uusbdev.DeviceName.CompareTo(dev.DeviceName)=0 Then
PreserveUSBDeviceLock.Unlock
Return
End If
Log("authorization!")
Uusbdev=dev
IsusbReset=True
If IsRecord Then
xml.tabe1.UpdateCell(UsbSetRow.Col,UsbSetRow.Row,Uusbdev.DeviceName.SubString(Uusbdev.DeviceName.LastIndexOf("/")+1))
End If
PreserveUSBDeviceLock.Unlock
Log("PreserveUSBDeviceLock.Unlock")
Return
End If
Next
Uusbdev=Null
PreserveUSBDeviceLock.Unlock
End Sub
Note: Getting the USB device function is done in a thread through a call to RunOnGuiThread ().However, any thread that Thread.sleep () will exit with an exception when the USB permission pop-up box appears ( English is not my first language. )
This is my test of the problem
EN~I have solved the problem .
But I was curious, when I clicked on the USB permissions TAB, the screen turned black and quickly recovered.
Threads that call the thread.sleep() function will also close because of an exception
This is my test of the problem
EN~I have solved the problem .
But I was curious, when I clicked on the USB permissions TAB, the screen turned black and quickly recovered.
Threads that call the thread.sleep() function will also close because of an exception
It seems to be related to an Android activity, ondestruction-onCreate
Activities were destroyed and rebuilt.(This is my guess, English is not my native language.)