I'm trying to connect my Glass with Arduino and a Wifi Shield.
At MenuActivity.java I call (and others methods... but this is the call) :
protected void onCreate(Bundle savedInstanceState)
{
new ConnexioArduino().execute();
super.onCreate(savedInstanceState);
}
And my ConnexioArduino.java :
private boolean socketReady;
private BufferedWriter outA;
private BufferedReader inA;
private Socket mySocket;
....
....
@Override
protected Void doInBackground(Void... params) {
socketReady = true;
String Host = "192.168.43.177";
int Port = 10001;
outA = null;
inA = null;
mySocket = null;
try {
mySocket = new Socket(Host, Port);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mySocket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
So it only does a connexion between Glass-Arduino Wifi Shield through Socket. But when I execute my app it stops and it gives me the following error : (see image on this link, sorry for the URL I don't have the enough reputation)
Share your manifest, it should have:
<uses-permission android:name="android.permission.INTERNET"/>
If not you will get a socket failed:eacces (permission denied) error if you step-debug.
Another possible problem is that your server is not accepting the socket request for any number of reasons.
I was able to use your exact code, set up a basic node server on a laptop, and open and close the socket without a crash.
Socket code on Glass should be just like Android according to this:
https://code.google.com/p/google-glass-api/issues/detail?id=272
If you continue to have issues log out the value of e in the exceptions you are catching and paste the result into your question.