title: Using an exported service in another app on Android
body: <p>I have a main app that includes a service and a second app that wants to make use of that service.</p>
  
  <p>The main app has this in the manifest (not inside an activity):</p>
  
  <pre><code>&lt;service
      android:name="com.example.foo.XMPPService"
      android:exported="true"
      android:process="xmppService" /&gt;
  </code></pre>
  
  <p>In the second app I try to bind to it:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setClassName("com.example.foo", "com.example.foo.XMPPService");
  bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>Unable to start activity ComponentInfo{com.example.app2/com.example.app2.MainActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.example.foo/.XMPPService }
  </code></pre>
  
  <p>So I'm wondering why this is not allowed, while I set "exported" to true.</p>