title: Android 's requestPermissions on landscape but the dialog shown in portrait before rotate to landscape
body: <p>My app starts on landscape as intended and I want to ask for permission with requestPermissions().</p>
  <p>However, the permission dialog first shown in portrait then its rotate itself to landscape which behavior I don't like. I want the permission dialog start in landscape from the start.</p>
  <p>I tried adding requestPermissions() in onViewCreated and onResume but still the same behavior.</p>
  <p>I move the permission related codes to PermissionsFragment and using callback when successfully acquired all permissions.</p>
  <p>Even when doing this all without that PermissionsFragment and done in MainActivity will result in the same behaviour as well. I even tried adding the permission codes in onPostResume to no avail.</p>
  <p>Is there anyway to force the permission dialog to show in landscape mode straight away?</p>
  <p><strong>MainActivity:</strong></p>
  <pre><code>public class MainActivity extends AppCompatActivity {
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          PermissionsFragment firstFragment = new PermissionsFragment();
          getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, firstFragment).commit();
      }
  
      @Override
      public void onAttachFragment(Fragment fragment) {
          if (fragment instanceof PermissionsFragment) {
              ((PermissionsFragment) fragment).setOnPermissionsAcquiredListener(() -&gt; {
                  MainFragment mainFragment = new MainFragment();
                  transaction.replace(R.id.fragment_container, mainFragment, &quot;MainFragment&quot;).commit();
              });
          }
      }
  
  }
  </code></pre>
  <p><strong>PermissionsFragment:</strong></p>
  <pre><code>public class PermissionsFragment extends Fragment {
      private PermissionsAcquiredListener callback;
  
      private static final int PERMISSIONS_REQUEST_CODE = 10;
      private static final String[] PERMISSIONS_REQUIRED = {
              permission.CAMERA,
              permission.READ_EXTERNAL_STORAGE,
              permission.WRITE_EXTERNAL_STORAGE,
              permission.INTERNET,
      };
  
      public void setOnPermissionsAcquiredListener(PermissionsAcquiredListener callback) {
          this.callback = callback;
      }
  
      private boolean hasPermissions() {
          // check for permission
      }
  
      @Override
      public void onResume() {
          super.onResume();
          LOGGER.d(&quot;[PERM] onResume&quot;);
  
          if (!hasPermissions()) {
              requestPermissions(PERMISSIONS_REQUIRED, PERMISSIONS_REQUEST_CODE);
          } else {
              callback.onPermissionsAcquired();
          }
      }
  
      @Override
      public void onRequestPermissionsResult(
              int requestCode, String[] permissions, int[] grantResults) {
          super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  
          // some codes checking
  
          // if all permissions are okay
          callback.onPermissionsAcquired();
      }
  
      // callback when permissions successfully acquired
      public interface PermissionsAcquiredListener {
          void onPermissionsAcquired();
      }
  }
  </code></pre>
  <p><strong>[Edit]</strong></p>
  <p>Currently I added delay before checking permission. This is just a temporary solution though.</p>
  <pre><code>    private Runnable task = () -&gt; requestPermissions(PERMISSIONS_REQUIRED, PERMISSIONS_REQUEST_CODE);
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          if (!hasPermissions()) {
              Handler handler = new Handler();
              handler.postDelayed(task, 500);
  
          } else {
              callback.onPermissionsAcquired();
          }
      }
  </code></pre>