title: How to make call the phone intent properly in Kotlin?
body: <p>I tried to call the phone intent on Kotlin, like this:</p>
  
  <pre><code> imgPhone.setOnClick {
              val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "1122334455"))
              startActivity(intent)
          }
  </code></pre>
  
  <p>When the phone image is clicked, nothing visually happens. Turns out the debugger showed you this:</p>
  
  <blockquote>
    <p>java.lang.SecurityException: Permission Denial: starting Intent {
    act=android.intent.action.CALL dat=tel:xxxxxxxxxx
    cmp=com.android.server.telecom/.components.UserCallActivity }</p>
  </blockquote>
  
  <p>I've tried several solutions:</p>
  
  <ol>
  <li>Put this line in AndroidManifest.xml:         </li>
  </ol>
  
  <blockquote>
    <p>&lt; uses-permission android:name="android.permission.CALL_PHONE"/></p>
  </blockquote>
  
  <ol start="2">
  <li><p>Add <strong>android:exported="true"</strong> at the activity on which the call intent is 
  invoked:</p>
  
  <blockquote>
  <pre><code>&lt; activity android:name=".activities.ProfileActivity" android:exported="true"/&gt;
  </code></pre>
  </blockquote></li>
  <li><p>Ask permission explicitely:</p>
  
  <pre><code>override fun onCreate() {
  super.onCreate()
  /*
  more codes here
  */
  setupPermissions()
   }
  
  fun setupPermissions() {
  val permission = ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE)
  
      if (permission != PackageManager.PERMISSION_GRANTED) {
      Log.i("Error", "Permission to call denied")
      }
  }
  </code></pre></li>
  </ol>
  
  <p>So far, none of those workarounds work (on Android 6). The same SecurityException still occurs. What is the proper solution, then?   </p>