title: Permission issue while starting a service from android
body: <p>I have written a service as part of an application. I try to call this service from a second application using the following code:</p>
  
  <pre><code>    Intent intent = new Intent () ;
      intent.setClassName("com.test" ,"com.test.DownloadService") ;
      // Create a new Messenger for the communication back
      Messenger messenger = new Messenger(handler);
      intent.putExtra("MESSENGER", messenger);
      intent.setData(Uri.parse("http://www.vogella.com/index.html"));
      intent.putExtra("urlpath", "http://www.vogella.com/index.html");
      this.startService(intent);
  </code></pre>
  
  <p>It gives the following exception</p>
  
  <pre><code>07-10 09:27:28.819: ERROR/AndroidRuntime(4226): FATAL EXCEPTION: main
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inject/com.inject.MyActivity}: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1971)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1996)
      at android.app.ActivityThread.access$700(ActivityThread.java:126)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1156)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:4458)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
      at dalvik.system.NativeStart.main(Native Method)
      Caused by: java.lang.SecurityException: Not allowed to start service Intent { dat=http://www.vogella.com/index.html cmp=com.test/.DownloadService (has extras) } without permission not exported from uid 10109
      at android.app.ContextImpl.startService(ContextImpl.java:1122)
      at android.content.ContextWrapper.startService(ContextWrapper.java:359)
      at com.inject.MyActivity.onCreate(MyActivity.java:28)
      at android.app.Activity.performCreate(Activity.java:4465)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1935)
      ... 11 more
  </code></pre>
  
  <p>Why this permission issue occurs?</p>
  
  <p>The following code works perfect when I call the service from the same app:</p>
  
  <pre><code>    Intent intent = new Intent(this, DownloadService.class);
      // Create a new Messenger for the communication back
      Messenger messenger = new Messenger(handler);
      intent.putExtra("MESSENGER", messenger);
      intent.setData(Uri.parse("http://www.vogella.com/index.html"));
      intent.putExtra("urlpath", "http://www.vogella.com/index.html");
      startService(intent);
  </code></pre>
  
  <p>Can someone please let me know why I get this permission issue when I call the service from a different application, though I have given all the required permissions in App2's manifest.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Manifest of App2</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.inject"
        android:versionCode="1"
        android:versionName="1.0"&gt;
  &lt;uses-sdk android:minSdkVersion="14"/&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;application android:label="@string/app_name" android:icon="@drawable/ic_launcher"&gt;
      &lt;activity android:name="MyActivity"
                android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN"/&gt;
              &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Manifest of App1 which contains the service</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.test"
        android:versionCode="1"
        android:versionName="1.0"&gt;
  &lt;uses-sdk android:minSdkVersion="14"/&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
      &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
  
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;service android:name="DownloadService" &gt;
      &lt;/service&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>