title: How to On location access programmatically in android
body: <p>I am creating an app and i am <strong>getting error</strong> in my <strong>location access</strong> of mobile in app. please help me. using following code......</p>
  
  <pre><code>  public static boolean isLocationEnabled(Context context) {
      int locationMode = 0;
      String locationProviders;
  
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M){
          try {
              locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
  
          } catch (Settings.SettingNotFoundException e) {
              e.printStackTrace();
          }
  
          return locationMode != Settings.Secure.LOCATION_MODE_OFF;
  
      }else{
          locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
          return !TextUtils.isEmpty(locationProviders);
      }
  
  
  }
  </code></pre>
  
  <p>i am getting error in this </p>
  
  <blockquote>
    <p>"locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);"</p>
  </blockquote>
  
  <p>please tell me how to resolve it.
  Thanks
  <a href="http://i.stack.imgur.com/8u4kD.png" rel="nofollow">click here what i want</a></p>