title: Android Asking Permission at Runtime Throwing Exception
body: <p>I was trying to request permission at run time in android marshmallow. But my app is crashing here is my code. </p>
  
  <pre><code>private void showWebpage() {
      if (checkSelfPermission(Manifest.permission.INTERNET) == PackageManager.PERMISSION_GRANTED) {
          Toast.makeText(this, "Permission Granted", Toast.LENGTH_LONG).show();
      } else {
  
          requestPermissions(new String[]{Manifest.permission.INTERNET},REQUEST_INTERNET);
      }
  }
  
  @Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }
  </code></pre>
  
  <p>When I am calling the showWebpage() method the app is crashing. The control is going to the else part and calling the requestPermissions method but the app is crashing.
  here is my logcat error </p>
  
  <pre><code>11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader: Failed to read uid_cputime
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader: java.io.FileNotFoundException: /proc/uid_cputime/show_uid_stat: open failed: ENOENT (No such file or directory)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at libcore.io.IoBridge.open(IoBridge.java:452)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:76)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:103)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileReader.&lt;init&gt;(FileReader.java:66)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.KernelUidCpuTimeReader.readDelta(KernelUidCpuTimeReader.java:71)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8031)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.BatteryStatsImpl$MyHandler.handleMessage(BatteryStatsImpl.java:155)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.Handler.dispatchMessage(Handler.java:102)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.Looper.loop(Looper.java:148)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.HandlerThread.run(HandlerThread.java:61)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.server.ServiceThread.run(ServiceThread.java:46)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:  Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at libcore.io.Posix.open(Native Method)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at libcore.io.IoBridge.open(IoBridge.java:438)
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:76) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:103) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at java.io.FileReader.&lt;init&gt;(FileReader.java:66) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.KernelUidCpuTimeReader.readDelta(KernelUidCpuTimeReader.java:71) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8031) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.internal.os.BatteryStatsImpl$MyHandler.handleMessage(BatteryStatsImpl.java:155) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.Handler.dispatchMessage(Handler.java:102) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.Looper.loop(Looper.java:148) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at android.os.HandlerThread.run(HandlerThread.java:61) 
  11-14 01:33:11.575 1092-1106/system_process E/KernelUidCpuTimeReader:     at com.android.server.ServiceThread.run(ServiceThread.java:46) 
  </code></pre>
  
  <p>Please help me, its really important :(</p>