title: How to Give Screen Overlay Permission On My Activity
body: <p>In My application I am getting Screen Overlay Issue in android 6+
  I tried to Turn on But for that I need to Give a Permission for Screen Overlay</p>
  
  <p>I followed <a href="https://gist.github.com/Aeonitis/2337b1ca652173839395be82db7d05c3" rel="noreferrer">this</a> I am unable to Integrate in my activity </p>
  
  <p>I also Tried <a href="https://stackoverflow.com/a/39763227/5010291">this</a> seems both are working so I want to Integrate them in my activity</p>
  
  <p>This is my activity :</p>
  
  <pre class="lang-java prettyprint-override"><code>public class MainActivity extends Activity {
  
      public static final int R_PERM = 123;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.data);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
          if ((CheckPermission(this, Manifest.permission.CAMERA)) &amp;&amp;
                  (CheckPermission(this, Manifest.permission.READ_PHONE_STATE)) &amp;&amp;
                  (CheckPermission(this, Manifest.permission.NFC))) {
              PermHandling();
          } else {
              RequestPermission(MainActivity.this, Manifest.permission.CAMERA, R_PERM);
              RequestPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE, R_PERM);
              RequestPermission(MainActivity.this, Manifest.permission.NFC, R_PERM);
  
              //NewPermHandling();
          }
  
      }
  
      private void PermHandling() {
          //My app internal parts....
          //Here my stuff works...
      }
  
      //private void NewPermHandling(){
  
      //}
  
      @Override
      public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) {
  
          switch (permsRequestCode) {
  
              case R_PERM: {
                  if (grantResults.length &gt; 0
                          &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                      PermHandling();
                  } else {
                      //Toast.makeText(this, "Please Grant Permissions other wise app will close.!", Toast.LENGTH_SHORT).show();
                  }
                  return;
              }
          }
      }
  
      public void RequestPermission(Activity thisActivity, String Permission, int Code) {
          if (ContextCompat.checkSelfPermission(thisActivity,
                  Permission)
                  != PackageManager.PERMISSION_GRANTED) {
              if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                      Permission)) {
              } else {
                  ActivityCompat.requestPermissions(thisActivity,
                          new String[]{Permission},
                          Code);
              }
          }
      }
  
      public boolean CheckPermission(Context context, String Permission) {
          if (ContextCompat.checkSelfPermission(context,
                  Permission) == PackageManager.PERMISSION_GRANTED) {
              return true;
          } else {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>Can any one suggest me how to give Screen orientation permission in my activity
  So that User No need to give it or worry about it Please help
  Here I tried but I don't know about <strong><code>PERM_REQUEST_CODE_DRAW_OVERLAYS</code></strong></p>
  
  <p>Any one Please Help me on my activity this is not duplicate or something else I am asking How to add it in my activity</p>