我必须首先找到图像的矩阵,我有这个代码,这给了我一个错误public class RingerModeStateReceiver extends BroadcastReceiver {
MainActivity mainActivity = new MainActivity();
public RingerModeStateReceiver() {
}
@Override // when the android sends a broadcast message that the RingerModeState has changed
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
int ringMode = audioManager.getRingerMode();
if (ringMode == AudioManager.RINGER_MODE_NORMAL){
context.stopService(new Intent(context, CallDetectService.class));
mainActivity.showStatusBarIcon("App","App InActive", false);
}
//throw new UnsupportedOperationException("Not yet implemented");
}
“java.lang.ArrayIndexOutOfBoundsException:坐标超出范围!”
这个错误的原因是什么?
L[row][col] = image.getRGB(row, col);
the error is
答案 0 :(得分:0)
方法getRGB()
有此签名
public int getRGB(int x, int y)
所以这行代码
L[row][col] = image.getRGB(row, col);
需要更改
L[row][col] = image.getRGB(col, row);
答案 1 :(得分:0)
您在getRGB()
方法中颠倒了X et Y的顺序。
尝试使用:L[row][col] = image.getRGB(col, row);