sockets - Inter-process communication in Android -
i trying develop android app reads loaded html contents in webview(of background running app).
getting idea chrome remote debugging, forwards tcp connections in particular port unix domain socket
adb forward tcp:9222 localabstract:webview_devtools_remote_"process_id"
i tried communicate webview_devtools_remote_pid socket using localsocket as
//https://developer.chrome.com/devtools/docs/protocol/1.1/page#command-enable jsonobject jo = new jsonobject(); jo.put("id", 1); jo.put("method", "page.enable"); localsocket s = new localsocket(); try { s.connect(new localsocketaddress("webview_devtools_remote_<p_id>")); outputstream oss = s.getoutputstream(); oss.write(jo.tostring().getbytes("utf-8")); inputstream iss = s.getinputstream(); integer i; string res = ""; while((i = iss.read()) != -1) { res += i.tostring(); } } catch (exception e) { log.e("error", e.tostring()); }
but getting connection resetted peer everytime.
edit: getting java.io.ioexception: broken pipe
any ideas issue.
is there someother easier way accomplish ?
i assume, trying connect remote web debugging socket application runs on same device? possible if app running "root", or "shell" user, or if signed same key app connecting to, see the code.
once resolve this, need adhere devtools remote debugging protocol in order html contents of page, see the list of existing remote debugging clients , libraries.
Comments
Post a Comment