2 개의 Android 활동을 통해 2 개의 변수를 전달하려고합니다. 그 중 하나는 마지막 페이지에 null를 높이 지 계속 :Android 인 텐트를 통해 변수를 전달할 때 NumberFormatException이 발생했습니다.
첫 번째 활동 :
두 번째 활동Intent intent= new Intent(RoundOptionActivity.this, MoveOptionActivity.class);
intent.putExtra("numRounds", "5");
startActivity(intent);
:
Bundle extras = getIntent().getExtras();
if(extras !=null) {
numRounds = Integer.parseInt(extras.getString("numRounds"));
}
.........
Intent intent = new Intent(MoveOptionActivity.this, MoveActivity.class);
intent.putExtra("numRounds", numRounds);
intent.putExtra("playerChoice", playerChoice);
startActivity(intent);
은 (주는이 시점에서 나는 로그 캣에 numRounds 인쇄
: 그것은 올바른 번호, NOT NULL)에 세 번째 작업을 설정
이 시점에서 numRounds를 정수로 구문 분석하려고 시도하는 행에서 응용 프로그램이 충돌하고 null 값을 구문 분석 할 수 없다고 불평하는 NumberFormatException이 발생합니다. playerChoice에는 문제가 없으며 numRounds 만 있습니다. 나는 playerChoice와 똑같은 방식으로 numRounds를 처리하려고 시도했지만 아무것도 작동하지 않는 것 같습니다. 무슨 일이야? D :
아! 나는 실제로 전에 그것을 시도했다. 그리고 그것은 그런 어떤 방법도 없다고 말했다. 또한 왜 2 번째 활동에서 int로 파싱했는지 모르겠지만 3 번째가 아니라 매우 이상합니다. 어쨌든, 그 덕분에, 고마워! =) –