I am trying to establish a connection between my android application and chrome on android. I am using LocalSocket for socket communication as below:
JSONObject request = new JSONObject();
request.put("method", "Page.reload");
LocalSocket s = new LocalSocket();
try {
s.connect(new LocalSocketAddress("chrome_devtools_remote", LocalSocketAddress.Namespace.ABSTRACT));
Log.i("Chrome: ", "After local socket connect");
//StringBuilder request = new StringBuilder().append("GET /json HTTP/1.0\r\n");
OutputStream oss = s.getOutputStream();
byte[] buffer = jo.toString().getBytes("utf-8");
oss.write(buffer, 0, buffer.length);
Log.i("Chrome: ", "outbuf size " + Integer.toString(s.getSendBufferSize()));
InputStream iss = s.getInputStream();
Integer i;
String res = "";
while ((i = iss.read()) != -1) {
res += i.toString();
}
Log.i("Chrome: ", res);
} catch (Exception e) {
Log.e("Error", "Connecting Local Socket "+e.toString());
}
I am able to establish the connection between Chrome and my App, but I am not able to send and receive messages to automate page loads in chrome.