I want to make an android wifi direct app to transfer data. And I'm following wifidirect demo tutorial. Now I have connected two devices. In that tutorial a asyncTask is used to server side part in the onConnectionavailableInfo() method and under :
If( info.groupFormed && info.isGroupOwner)
And inside that asyncTask do InBackground :
ServerSocket server = new ...
Socket socket = server.accept()
...
(These lines of code is just for addressing)
I want to know can I simply and directly use a thread and a runnable in it inside the onConnectionInfoAvailable for accepting data from client? Can I use server.accept into a runnable without causing error? Or I have to use a asyncTask. Thanks.