WifiDirectActivity Sample Change: Port ArrayList <String> p2p
I reviewed the Android wifi p2p API here and looked at the code example provided in โWiFiDirectActivityโ, which simply allows phones to transfer image files from one phone to another. The code they use for this:
public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } I changed it to the following without compiler errors:
public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps ArrayList<String> deck = new ArrayList<String>(); deck.add("Lulz"); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("ArrayList<String>"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } The problem is that transferring is only one way, and it only transfers files, whereas I would like to implement it in my pvp card application code in order to transfer ArrayList BOTH objects in ways. How can i do this?
Also, how can I transfer the current "ArrayList" deck that I created there to get started? I do not need to search, I recognize the name ArrayList inside the code.
I am not going to compose a solution for you, and you have probably already found a solution to your problem. But just in case you do not have:
Sending ArrayList <String> from server to client side via TCP over socket?
The above link seems to cover your ArrayList through the socket issue. One comment suggested you better send primitive strings and then create an array on the other end. Wi-Fi Direct Bandwidth should easily handle this, but then it should also handle ArrayList transmission.
Regarding two-way communication, I will connect you with this , which, of course, led me to understand two-way sockets on Android, input and output streams, etc. It is also recommended that you read the sockets in the Oracle Documentation .
Wi-Fi Direct is still in its infancy. Good luck.