0

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.

klaymen
  • 237
  • 2
  • 10
  • 1
    Did you check http://stackoverflow.com/questions/18480206/asynctask-vs-thread-in-android ? –  Apr 08 '16 at 12:39
  • Thanks. I read it. But still I don't know which one is fit my target. I want to stream videos and transfer images. – klaymen Apr 08 '16 at 13:06
  • 1
    I'd advice you to use AsyncTask... –  Apr 11 '16 at 08:07

0 Answers0