ArrayIndexOutOfBoundsException для массива разрешений с длиной = 0 - PullRequest
0 голосов
/ 07 июля 2019

В строке 7 произошла ошибка. Я получил эту ошибку:

java.lang.ArrayIndexOutOfBoundsException: length = 0; индекс = 0

в этом коде Java:

public void onRequestPermissionsResult(int requestCode, String[] 
        permissions, int[] grantResults) {
    if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

    } else {
        if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0]) /* the line where the error occurs */) {
        } else {
            Toast.makeText(this, "This application needs permission to read your SMS to automatically verify your "
                    + "phone, you may disable the permission once you have been verified.", Toast.LENGTH_LONG)
                    .show();
        }
    }
    initiateVerificationAndSuppressPermissionCheck(message);
}

Как я могу исправить эту ошибку

...