title: How to use custom permissions in Android?
body: <p>I have two applications.</p>
  
  <p>One is declaring permission and having single <code>Activity</code>:</p>
  
  <p>Part of <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:permission="your.namespace.permission.TEST" &gt;
      &lt;activity
          android:name=".DeclaringPermissionActivity"
          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;intent-filter&gt; 
           &lt;action android:name="android.intent.action.VIEW" /&gt; 
           &lt;category android:name="android.intent.category.DEFAULT" /&gt; 
           &lt;category android:name="android.intent.category.BROWSABLE" /&gt; 
           &lt;data android:scheme="myapp"
               android:host="myapp.mycompany.com" /&gt; 
          &lt;/intent-filter&gt; 
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>The second declares that is uses permission</p>
  
  <p>Part of <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="10" /&gt;
  &lt;uses-permission android:name="your.namespace.permission.TEST" /&gt;
  
  &lt;application
  </code></pre>
  
  <p>Part of <code>Activity</code>:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://myapp.mycompany.com/index")));
  }
  </code></pre>
  
  <p>I'm installing the application declaring permission, then I run the second application. </p>
  
  <p>In a result I get security exception:</p>
  
  <pre><code> 01-11 09:46:55.249: E/AndroidRuntime(347): java.lang.RuntimeException: Unable to start activity ComponentInfo{your.namespace2/your.namespace2.UsingPErmissionActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=myapp://myapp.mycompany.com/index cmp=your.namespace/.DeclaringPermissionActivity } from ProcessRecord{407842c0 347:your.namespace2/10082} (pid=347, uid=10082) requires your.namespace.permission.TEST
  </code></pre>