title: Android applications obtain permission cannot run normally
body: <p>Wrote a get contacts and contact phone number and then displayed in the small program, but after get permission in Android 6 cannot display the data, to restart the program to read properly. I think it should be there access out of the question, because after restart the authority need not ask when can read properly, and need the pop-up dialog asking while allowing access permissions but still can't show, but after the restart.</p>
  
  <pre><code> public class MainActivity extends AppCompatActivity {
   
      ListView contactsView;
   
      ArrayAdapter&lt;String&gt; adapter;
   
      List&lt;String&gt; contactsList = new ArrayList&lt;String&gt;();
   
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          contactsView = (ListView) findViewById(R.id.contacts_view);
          adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.
                  simple_list_item_1, contactsList);
          contactsView.setAdapter(adapter);
          insertDummyContactWrapper();
      }
   
      final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
   
      private void insertDummyContactWrapper() {
          int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS);
          if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {
              requestPermissions(new String[] {Manifest.permission.READ_CONTACTS},
                      REQUEST_CODE_ASK_PERMISSIONS);
              return;
          }
          readContacts();
      }
   
      @Override
      public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
          switch (requestCode) {
              case REQUEST_CODE_ASK_PERMISSIONS:
                  if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                      // Permission Granted
                      readContacts();
                  } else {
                      // Permission Denied
                      Toast.makeText(MainActivity.this, "READ_CONTACTS Denied", Toast.LENGTH_SHORT)
                              .show();
                  }
                  break;
              default:
                  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
          }
      }
   
      public void readContacts() {
          Cursor cursor = null;
          try {
              cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                      null, null, null, null);
              while (cursor.moveToNext()) {
                  String displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.
                          CommonDataKinds.Phone.DISPLAY_NAME));
                  String number = cursor.getString(cursor.getColumnIndex(ContactsContract.
                          CommonDataKinds.Phone.NUMBER));
                  contactsList.add(displayName + "\n" + number);
              }
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              if (cursor != null) {
                  cursor.close();
              }
          }
      }
  </code></pre>