title: call require permission which may be rejected by user
body: <p>i need get location in android....
  i write this code :</p>
  
  <pre><code>    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Button button = (Button) findViewById(R.id.button);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  
              if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)
                      !=PackageManager.PERMISSION_GRANTED)
              {
                  if(ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,Manifest.permission.ACCESS_FINE_LOCATION))
                  {
                      Toast.makeText(MainActivity.this,"Comment...",Toast.LENGTH_LONG).show();
                  }
                  else
                  {
                      ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1);
                  }
              }
              else
              {
                  //Call whatever you want
                  myPermissionNeededMethod();
              }
          }
  
      });
  }
  @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      switch (requestCode){
          case 1: {
              if((grantResults.length&gt;0) &amp;&amp; grantResults[0]==PackageManager.PERMISSION_GRANTED)
                  myPermissionNeededMethod();
              else{
                  // the user deny to giving permission so we ask him again or whatever we need to do !
              }
              return;
  
          }
      }
  }
  </code></pre>
  
  <p>in myPermissionNeededMethod() i write:</p>
  
  <pre><code>    public  void  myPermissionNeededMethod(){
      LocationManager locationManager =  (LocationManager) getSystemService(LOCATION_SERVICE);
      Location location= locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
  
  }
  </code></pre>
  
  <p>but again i recieved error call require permission which may be rejected by user ....!!!!
  if me can not use  myPermissionNeededMethod() method me should be copy code in else section in oncreate and onRequestPermissionsResult ....!!!</p>