Why is there a need to use thread in android to receive data from the bluetooth remote device?

StackOverflow https://stackoverflow.com/questions/8686229

  •  10-04-2021
  •  | 
  •  

Question

I have been doing some research lately over my work project, i am trying to read card swipe data from Bluetooth card reader in my app.

So as to get that data i have to use thread, i know the reason why is there a need to use so as this process does not hinder interface activity, but here my concern is not to handle interface activity at the time of fetching data. But threading makes sense when there is a need of BluetoothServerSocket so as to have full duplex connection. So my question basically is that if i am just receiving data from remote device do i really need to have a BluetoothServerSocker under Thread?

Was it helpful?

Solution

When you are doing some action that is going to take some time in performance, then it is better to use Thread. When you are reading Data from Bluetooth Card Reader, then in this case, in background many activities take place. for e.g. Bluetooth Connection, Device Discovery, Pairing, Asking for permission , retrieving data. It may be possible cause of device hang or user may not like to be in wait state. so to prevent such cases it is better to use Thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top