gpt4 book ai didi

java - DialogFragment 上的 ArrayIndexOutOfBoundsException 崩溃

转载 作者:行者123 更新时间:2023-12-02 06:27:39 25 4
gpt4 key购买 nike

我有一个对话框,我想在其中查看应用程序所需的所有权限。从 Intent 恢复的应用程序的包名称。代码是这样的

不幸的是,当我打开带有 java.lang.ArrayIndexOutOfBoundsException: length=3; 的对话框时,我的应用程序崩溃了。权限上的索引=3.append(requestedPermissions[i]+"\n"); 为什么?我该如何修复?

最佳答案

permissions.append(requestedPermissions[i]+"\n");

上面的行应该出现在您的 for 循环中。目前它出现在 for 循环之后,这就是为什么 i 的值变为 3(因为 fori 变为 3) 时终止,给出 ArrayIndexOutOfBoundsException

我想您想像这样将所有权限附加到 TextView

for ( i = 0; i < requestedPermissions.length; i++) {
permissions.append(requestedPermissions[i]+"\n");
}

关于java - DialogFragment 上的 ArrayIndexOutOfBoundsException 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20380683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com