title: Android 6.0.1 - Permission issue = wifiManager.getScanResults() returns 0
body: <p>The permissionsList.add() doesn't work but MainActivity.this.requestPermissions() works fine. The issue is that it brings a dialog box asking if the user allow the location permission.</p>
  
  <p>Why adding the permission does not work?</p>
  
  <p>Is there a way to avoid the dialog box?</p>
  
  <p>See my minimal code below: </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  WifiManager wifiManager;
  WifiBroadcastReceiver broadcastReceiver;
  
  Context context;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      context = getApplicationContext();
  
      List&lt;String&gt; permissionsList = new ArrayList&lt;String&gt;();
      permissionsList.add(Manifest.permission.ACCESS_FINE_LOCATION);
      permissionsList.add(Manifest.permission.ACCESS_COARSE_LOCATION);
  
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
          if(checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp;
                  checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
              MainActivity.this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 100);
              MainActivity.this.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 100);
              }
          }
  
          Button scan = (Button) findViewById(R.id.scan);
  
          wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
          wifiManager.setWifiEnabled(true);
  
          scan.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                 if(wifiManager != null)
                      wifiManager.startScan();
              }
          });
  
  
          broadcastReceiver = new WifiBroadcastReceiver();
  
          // On attache le receiver au scan result
          registerReceiver(broadcastReceiver, new IntentFilter(
                  WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
  
      }
  
      public class WifiBroadcastReceiver extends BroadcastReceiver {
  
          private WifiManager wifiManager;
  
  
          @Override
          public void onReceive(Context context, Intent intent) {
              wifiManager = ((MainActivity) context).getCurrentWifiManager();
              List&lt;ScanResult&gt; listeScan = wifiManager.getScanResults();
            }
      }
  
  
      public WifiManager getCurrentWifiManager() {
          return wifiManager;
      }
  
   }
  </code></pre>
  
  <p>And here is the manifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.bernard_zelmans.checksecurity"&gt;
  
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".Ping"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>