title: How can my Android app communicate with a native daemon?
body: <p>So, I have a custom Android application running as System (built as a system app in my ROM). And Ive written a native daemon that works fine too and runs as root. However, I was wondering how the two can communicate? I know I can have the native daemon create a network socket and have the App connect to it, but using a local socket for IPC seems even better, but I am struggling to find example code for it. </p>
  
  <p>I figured I could create the socket like as described <a href="http://www.gnu.org/software/libc/manual/html_node/Local-Socket-Example.html" rel="noreferrer">here</a> but I have no idea how to communicate with it in Java. </p>
  
  <p>Any help would be much appreciated. </p>
  
  <p>Also, at first I wrote a native library and used JNI to communicate with it from Java, but quickly realized that it obviously runs in the context of the app, so it cant be run as root, which is a requirement I have, and something the native daemon can do fine. Is using sockets the best alternative here or would Binder work too?</p>
  
  <p>Thanks a ton!</p>