title: Proper way to handle ACTION_MANAGE_WRITE_SETTINGS activity
body: <p>I want write settings permission in order to start portable WLAN hotspot...</p>
  
  <p>this is what i got,</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
              if (!Settings.System.canWrite(getApplicationContext())) {
                  Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + getPackageName()));
                  startActivityForResult(intent, 200);
              }
          }
  </code></pre>
  
  <p>this works fine until i press back button after i grant permission.</p>
  
  <p>after pressing back button resultCode is 0 always, therefore further code is not working properly.</p>