title: Can't allow my app to use draw over other apps permission
body: <p>I forgot to add the permission in the manifest.</p>
  
  <p>Solved</p>
  
  <hr>
  
  <p><strong>Original Question</strong></p>
  
  <p>I'm developing a little app which allows UX testers to get informations from user's input in android.</p>
  
  <p>For this, I need to create a transparent view in top of all others.
  I try to get the permission this way : </p>
  
  <pre><code>    class MainActivity : AppCompatActivity() {
  
  
      val REQUEST_CODE = 10101
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          if (checkDrawOverlayPermission()) {
              //startService(Intent(this, TrackService::class.java))
          }
      }
  
      fun checkDrawOverlayPermission(): Boolean {
          if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.M) {
              return true
          }
          if (!Settings.canDrawOverlays(this)) {
              val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                      Uri.parse("package:" + packageName))
              startActivityForResult(intent, REQUEST_CODE)
              return false
          } else {
              return true
          }
      }
  
      @TargetApi(Build.VERSION_CODES.M)
      override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
          if (requestCode == REQUEST_CODE) {
              if (Settings.canDrawOverlays(this)) {
                  //startService(Intent(this, TrackService::class.java))
              }
          }
      }
  }
  </code></pre>
  
  <p>But, when I go to the windows (programmatically with this code), I can't grant the access.</p>
  
  <p>Do someone got this problem, or as a fix?</p>