title: Can't resolve "onRequestPermissionsResult"
body: <p>I am a Game developer and not good at android. I want to make a library class that "extends Service" which sends the GPS location.</p>
  
  <p>While I keep <code>onRequestPermissionsResult</code> in my exported google project in <code>"MainActivity"</code>, I don't get an issue. However, when I try to put it in my library class I start getting the following error.</p>
  
  <pre><code>    @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
      {
          super.onRequestPermissionsResult(requestCode, permissions, grantResults);
          if(grantResults.length&gt;0&amp;&amp;grantResults[0]== PackageManager.PERMISSION_GRANTED)
          {
              if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)==PackageManager.PERMISSION_GRANTED)
              {
                  mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 0, 0, locationListener);
              }
          }
      }
  </code></pre>
  
  <p>Can't resolve <code>"onRequestPermissionsResult"</code>.</p>
  
  <pre><code>
  //------------------------------------------------------------
  
      package hp.test.com.mylibrary;
  
  
      import android.Manifest;
      import android.app.Activity;    
      import android.app.Service; 
      import android.content.Context;       
      import android.content.Intent;
      import android.content.pm.PackageManager;  
      import android.location.Location; 
      import android.location.LocationListener; 
      import android.location.LocationManager;  
      import android.os.Build;  
      import android.os.Bundle; 
      import android.os.IBinder;
      import android.support.annotation.NonNull;
      import android.support.annotation.Nullable;
      import android.support.v4.app.ActivityCompat; 
      import android.support.v4.content.ContextCompat; 
  
      public class GpsLocation  extends Service {
          public static GpsLocation Instance;                       
          public  LocationManager   mLocationManager;                         
          public  LocationListener  locationListener;                        
          public  Context mainContext;                                             
          public  Activity mainActivity;                                                        
          public  String[] premition={Manifest.permission.ACCESS_FINE_LOCATION};                 
  
  
          public static GpsLocation Instance ()                 
          {                                    
              if(Instance==null)                                         
              {                                           
                  Instance = new GpsLocation();                                
              }                                                       
              return Instance;                                          
          }                                              
  
          public void setMainContext(Context context)                           
          {
              System.out.println("********** setMainContext");
              mainContext=context;
          }
          public void setmainActivity(Activity activity)
          {
              mainActivity=activity;
              System.out.println("********** setmainActivity"+ mainActivity);
          }
          public   void OpenLocationSeating()
          {
              mainActivity.startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
          }
  
  
  
  
  
  
  
          public void CreateData()
          {
              mLocationManager = (LocationManager) mainContext.getSystemService(LOCATION_SERVICE);
              locationListener = new LocationListener()
              {
                  @Override
                  public void onLocationChanged(Location location) {
                      System.out.println("********** onLocationChanged"+location.toString());
                  }
  
                  @Override
                  public void onStatusChanged(String s, int i, Bundle bundle) {
                      System.out.println("********** onStatusChanged");
  
                  }
  
                  @Override
                  public void onProviderEnabled(String s) {
                      System.out.println("********** onProviderEnabled");
  
                  }
  
                  @Override
                  public void onProviderDisabled(String s) {
                      System.out.println("********** onProviderDisabled");
  
                  }
              };
              checkPermissions();
          }
  
  
  
  
  
          public   void checkPermissions()
          {
              if (Build.VERSION.SDK_INT &gt;= 23)
              {
                  if (ActivityCompat.checkSelfPermission(mainContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(mainContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
                  {
                      ActivityCompat.requestPermissions(mainActivity,premition,1);
                  }else
                  {
                      mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 0, 0, locationListener);
                  }
              }
              else {
              }
          }
  
  
  
  
          public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
          {
              super.onRequestPermissionsResult(requestCode, permissions, grantResults);
              if(grantResults.length&gt;0&amp;&amp;grantResults[0]== PackageManager.PERMISSION_GRANTED)
              {
                  if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)==PackageManager.PERMISSION_GRANTED)
                  {
                      mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 0, 0, locationListener);
                  }
              }
          }
  
          @Nullable
          @Override
          public IBinder onBind(Intent intent) {
              return null;
          }  }
  
  </code></pre>